Skip to content

비교 번역 pull 요청합니다. #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 32 additions & 36 deletions 1-js/02-first-steps/08-comparison/article.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
- 보다 큼/작음: <code>a &gt; b</code>, <code>a &lt; b</code>.
- 보다 크거나/작거나 같음: <code>a &gt;= b</code>, <code>a &lt;= b</code>.
- 같음: `a == b` (2개의 `=`기호에 유의합니다. 하나의 기호 `a ​​= b`는 할당을 의미합니다).
- 같지 않음. 수학에서 표기법은 다음과 같습니다. <code>&ne;</code>, 자바스크립트에서는 느낌표가 붙은 할당연산자로 작성됩니다. <code>a != b</code>.
- 같지 않음: 수학에서 표기법은 다음과 같습니다. <code>&ne;</code>, 자바스크립트에서는 느낌표가 붙은 할당연산자로 작성됩니다. <code>a != b</code>.

## 불리언은 결과입니다.
## 결과는 논리 타입(boolean)입니다.

다른 모든 연산자와 마찬가지로 비교는 값을 반환합니다. 이 경우 값은 불리언 값입니다.

Expand Down Expand Up @@ -51,7 +51,6 @@ alert( 'Bee' > 'Be' ); // true
4. 각 문자열이 끝날 때까지 반복합니다.
5. 두 문자열이 같은 길이로 끝나면 두 문자열은 동일합니다. 그렇지 않으면 긴 문자열이 더 큽니다.

In the examples above, the comparison `'Z' > 'A'` gets to a result at the first step while the strings `"Glow"` and `"Glee"` are compared character-by-character:
위의 예제에서 문자열 `"Glow"` 와 `"Glee"`가 문자별로 비교되는 동안 비교-`'Z' > 'A'`는 첫 단계에서 결과에 도달합니다.

1. `G`는`G`와 같습니다.
Expand All @@ -62,12 +61,11 @@ In the examples above, the comparison `'Z' > 'A'` gets to a result at the first
위에 주어진 비교 알고리즘은 사전이나 전화번호부에서 사용된 알고리즘과 거의 동일하지만 정확하게 동일하지는 않습니다.

예를 들어, 대소문자가 중요합니다. 대문자 `"A"`는 소문자 `"a"`와 같지 않습니다. 어느 것이 더 큽니까? 소문자 `"a"`입니다. 왜? 소문자는 "자바스크립트가 사용하는 내부 인코딩 테이블"(유니 코드)에서 더 큰 인덱스를 갖기 때문입니다. <info:string> 주제에서 이에 대한 자세한 내용과 결과를 살펴 보겠습니다.

```

## 다른 타입간의 비교
- ## 다른 타입간의 비교

When comparing values of different types, JavaScript converts the values to numbers.
다른 유형의 값을 비교할 때 자바스크립트는 값을 숫자로 변환합니다.

예시:
Expand Down Expand Up @@ -104,12 +102,12 @@ alert( Boolean(b) ); // true
alert(a == b); // true!
```

자바스크립트의 관점에서 보았을 때, 이 결과는 매우 정상입니다. 항등 검사`==`는 숫자 변환(`"0"`을 `0`으로)을 사용하여 값을 변환하고, 반면 명시적인 '불리언'변환은 그 밖의 규칙을 사용합니다.
자바스크립트의 관점에서 보았을 때, 이 것은 매우 정상적인 결과입니다. 항등 검사`==`는 숫자 변환(`"0"`을 `0`으로)을 사용하여 값을 변환하고, 반면 명시적인 '불리언'변환은 또 다른 규칙을 사용합니다.
````

## 완전 항등 검사

일반적인 항등 검사`==`는 문제가 있습니다. 그것은 `0`과 `false`를 구별 할 수 없습니다.
일반적인 항등 검사`==`는 문제가 있습니다. 그것은 `0`과 `false`를 구별할 수 없다는 것입니다ㅣ.

```js run
alert( 0 == false ); // true
Expand All @@ -127,7 +125,6 @@ alert( '' == false ); // true

**완전 항등 연산자 `===`는 타입 변환없이 항등성을 검사합니다.**

In other words, if `a` and `b` are of different types, then `a === b` immediately returns `false` without an attempt to convert them.
다시 말해, `a`와 `b`가 다른 타입이라면, `a === b`는 변환하려고 시도하지 않고 즉시 `false`를 반환합니다.

해봅시다:
Expand All @@ -144,7 +141,7 @@ alert( 0 === false ); // false, because the types are different

좀 더 많은 사레를 살펴봅시다.

`null`또는 `undefined` 다른 값과 비교될 때 비직관적인 행동이 있습니다.
`null`또는 `undefined`으로 다른 값과 비교할 때 비직관적인 행동을 합니다.


완전 항등 검사`===`
Expand All @@ -155,63 +152,62 @@ alert( 0 === false ); // false, because the types are different
```

항등 검사`==`
: There's a special rule. These two are a "sweet couple": they equal each other (in the sense of `==`), but not any other value.
: 특별한 규칙이 있습니다. 이 두 가지는 "달콤한 커플"입니다 : 그들은 (`==`의 의미로) 서로 같지만 다른 값은 없습니다.
: 특별한 규칙이 있습니다. 이 두 가지는 "달콤한 커플"입니다 : 이 것들은 `==`을 사용하엿을 때 서로 동등하다고 나오지만 어떠한 값도 가지고 있지 않습니다.

```js run
alert( null == undefined ); // true
```

For maths and other comparisons `< > <= >=`
: `null/undefined` are converted to numbers: `null` becomes `0`, while `undefined` becomes `NaN`.
수학과 각각의 비교 `< > <= >=`
: `null/undefined`는 숫자로 변환됩니다. `null``0`이되고 `undefined``NaN`이 됩니다.

Now let's see some funny things that happen when we apply these rules. And, what's more important, how to not fall into a trap with them.
이제 이 규칙을 적용했을 때 일어나는 재미있는 일들을 확인합니다. 그리고 무엇이 더 중요한지, 어떻게 이것들과 함정에 빠지지 않는지 확인합니다.

### Strange result: null vs 0
### 이상한 결과 : null 0

Let's compare `null` with a zero:
`null`과 0을 비교합시다.

```js run
alert( null > 0 ); // (1) false
alert( null == 0 ); // (2) false
alert( null >= 0 ); // (3) *!*true*/!*
```

수학적으로 이 결과는 이상합니다. 마지막 결과는 "`null`이 0보다 크거나 같음"을 나타내고, 그래서 마지막 결과 위의 비교 중 하나는 `true`여야 하지만 둘 다 `false`입니다.

Mathematically, that's strange. The last result states that "`null` is greater than or equal to zero", so one of the comparisons above it must be correct, but they are both false.

The reason is that an equality check `==` and comparisons `> < >= <=` work differently. Comparisons convert `null` to a number, treating it as `0`. That's why (3) `null >= 0` is true and (1) `null > 0` is false.
그 이유는 항등 검사`==`와 비교`> < >= <=`가 다르게 작동하기 때문입니다. 비교는 `null`을 숫자로 변환하여 `0`으로 처리합니다. 이것이 (3) `null> = 0`이 true이고 (1)`null> 0`이 false 인 이유입니다.

On the other hand, the equality check `==` for `undefined` and `null` is defined such that, without any conversions, they equal each other and don't equal anything else. That's why (2) `null == 0` is false.
반면, `undefined``null`에 대한 항등 검사`==`는 이렇게 정의됩니다. 어떠한 변환도 없이 이 둘은 서로 같지만 다른 무엇과도 같지않습니다. 이것이 (2)`null == 0`이 거짓인 이유입니다.

### An incomparable undefined
### 비교할 수 없는 undefined

The value `undefined` shouldn't be compared to other values:
`undefined`값은 다른 값과 비교되어서는 안됩니다.

```js run
alert( undefined > 0 ); // false (1)
alert( undefined < 0 ); // false (2)
alert( undefined == 0 ); // false (3)
```

Why does it dislike zero so much? Always false!
왜 이것은 0을 싫어하나요? 항상 `false` 입니다!

We get these results because:
다음과 같은 이유로 이러한 결과를 얻습니다.

- Comparisons `(1)` and `(2)` return `false` because `undefined` gets converted to `NaN` and `NaN` is a special numeric value which returns `false` for all comparisons.
- The equality check `(3)` returns `false` because `undefined` only equals `null` and no other value.
- `(1)``(2)`는 `undefined``NaN`으로 변환되고 `NaN`이 모든 비교에 대해 `false`를 반환하는 특수한 숫자 값이기 때문입니다.
- `undefined`는 오직 `null`만 같고 동등한 다른 값은 없어서 항등검사`(3)`은 `false`를 반환합니다.

### Evade problems
### 문제 회피

Why did we go over these examples? Should we remember these peculiarities all the time? Well, not really. Actually, these tricky things will gradually become familiar over time, but there's a solid way to evade problems with them:
왜 이 예들을 검토하였을까요? 항상 이러한 특성을 기억해야 할까요? 글쎄요, 그렇진 않습니다. 사실, 이러한 까다로운 일들은 점차 익숙해 질 것입니다. 하지만 문제를 피할 수 있는 견고한 방법이 있습니다.

Just treat any comparison with `undefined/null` except the strict equality `===` with exceptional care.
완전 평등`===`을 제외한 `undefined/null`에 대한 모든 비교를 특별한 주의를 기울여 처리하십시오.

Don't use comparisons `>= > < <=` with a variable which may be `null/undefined`, unless you're really sure of what you're doing. If a variable can have these values, check for them separately.
뭘 하고 있는지 확신하지 못한다면, `>= > < <=`비교를 `null/undefined`일 수 있는 변수와 함께 사용하지 마십시오. 변수가 이 값을 가질 수 있으면, 변수를 개별적으로 검사하십시오.

## Summary
## 요약

- Comparison operators return a boolean value.
- Strings are compared letter-by-letter in the "dictionary" order.
- When values of different types are compared, they get converted to numbers (with the exclusion of a strict equality check).
- The values `null` and `undefined` equal `==` each other and do not equal any other value.
- Be careful when using comparisons like `>` or `<` with variables that can occasionally be `null/undefined`. Checking for `null/undefined` separately is a good idea.
- 비교 연산자는 불리언 값을 반환합니다.
- 문자열은 "사전"순서로 문자단위로 비교됩니다.
- 서로 다른 유형의 값을 비교하면 숫자로 변환됩니다 ("완전 항등 검사"는 제외하고).
- `null`값과 `undefined`값은 서로 같고`==` 다른 어떠한 값과도 같지 않습니다.
- 때때로 `null/undefined`일 수 있는 변수에 대해 `>` 또는 `<`같은 비교를 사용할 때 주의하십시오. 개별적으로 `null/undefined`를 체크하는 것은 좋은 생각입니다.
70 changes: 35 additions & 35 deletions 1-js/02-first-steps/09-alert-prompt-confirm/article.md
Original file line number Diff line number Diff line change
@@ -1,109 +1,109 @@
# Interaction: alert, prompt, confirm
# 상호 작용: 알림창, 입력창, 확인창

This part of the tutorial aims to cover JavaScript "as is", without environment-specific tweaks.
튜토리얼의 이 파트는 브라우저(Browser) 환경 특유의 조정 없이 "있는 그대로"의 자바스크립트를 다루는 것을 목표로합니다.

But we'll still be using the browser as our demo environment, so we should know at least a few of its user-interface functions. In this chapter, we'll get familiar with the browser functions `alert`, `prompt` and `confirm`.
그러나 우리는 여전히 브라우저(Browser)를 데모 환경으로 사용할 것이므로 최소한의 사용자 인터페이스 기능을 알아야 합니다. 이 챕터에서는 브라우저(Browser) 함수인 `alert`, `prompt`, `confirm`에 대해 알아 보겠습니다.

## alert
## 알림창(alert)

Syntax:
문법:

```js
alert(message);
```

This shows a message and pauses script execution until the user presses "OK".
이 메시지는 사용자가 확인("OK")을 누를 때까지 메시지를 표시하고 스크립트 실행을 일시 중지합니다.

For example:
예시:

```js run
alert("Hello");
```

The mini-window with the message is called a *modal window*. The word "modal" means that the visitor can't interact with the rest of the page, press other buttons, etc. until they have dealt with the window. In this case -- until they press "OK".
메시지가 있는 미니 창을 *모달창*(modal window)이라고 합니다. 모달"modal"이란 단어는 방문자가 창을 다룰 때까지 페이지의 나머지 부분과 상호 작용하거나 다른 버튼을 누르는 등의 작업을 수행할 수 없음을 의미합니다. 이 경우 - 확인("OK")를 누를 때까지 입니다.

## prompt
## 입력창(prompt)

The function `prompt` accepts two arguments:
`prompt`함수는 두 개의 인수를 받습니다.

```js no-beautify
result = prompt(title[, default]);
```

It shows a modal window with a text message, an input field for the visitor, and the buttons OK/CANCEL.
이 함수는 텍스트 메시지, 방문자를 위한 입력 필드(input field)과 확인/취소(OK/CANCEL) 버튼이 있는 모달 창을 보여줍니다.

`title`
: The text to show the visitor.
: 방문자에게 보여줄 텍스트입니다.

`default`
: An optional second parameter, the initial value for the input field.
: 선택사항인 두 번째 매개 변수는 입력 필드의 초기 값입니다.

The visitor may type something in the prompt input field and press OK. Or they can cancel the input by pressing CANCEL or hitting the `key:Esc` key.
방문자는 프롬프트 입력 필드에 내용을 입력하고 확인(OK)을 누릅니다. 또는 취소(CANCEL)을 누르거나 `key:Esc`키를 눌러 입력을 취소할 수 있습니다.

The call to `prompt` returns the text from the input field or `null` if the input was canceled.
`prompt`호출은 입력 필드에서 텍스트를 반환하거나 입력이 취소된 경우 `null`을 반환합니다.

For instance:
예시:

```js run
let age = prompt('How old are you?', 100);

alert(`You are ${age} years old!`); // You are 100 years old!
```

````warn header="In IE: always supply a `default`"
The second parameter is optional, but if we don't supply it, Internet Explorer will insert the text `"undefined"` into the prompt.
````warn header="IE 에서는 항상 '기본값'을 제공하십시오."
두 번째 매개변수는 선택사항이지만, 제공하지 않으면 Internet Explorer는 `"undefined"`텍스트를 프롬프트에 삽입합니다.

Run this code in Internet Explorer to see:
확인하기 위해 Internet Explorer에서 이 코드를 실행하십시오.

```js run
let test = prompt("Test");
```

So, for prompts to look good in IE, we recommend always providing the second argument:
따라서 IE에서 보기 좋게 prompt()를 실행하려면, 항상 두 번째 인수를 제공하는 것이 좋습니다.

```js run
let test = prompt("Test", ''); // <-- for IE
```
````

## confirm
## 확인창(confirm)

The syntax:
문법:

```js
result = confirm(question);
```

The function `confirm` shows a modal window with a `question` and two buttons: OK and CANCEL.
`confirm`함수는 질문(`question`)과 두 개의 버튼(OK/CANCEL)이 있는 모달 윈도우를 보여줍니다.

The result is `true` if OK is pressed and `false` otherwise.
OK를 누르면 `true`이고 그렇지 않으면 `false`입니다.

For example:
예시:

```js run
let isBoss = confirm("Are you the boss?");

alert( isBoss ); // true if OK is pressed
```

## Summary
## 요약

We covered 3 browser-specific functions to interact with visitors:
방문자와 상호작용할 수 있는 세 가지 브라우저 특유의 기능을 다뤘습니다.

`alert`
: shows a message.
: 메시지를 보여줍니다.

`prompt`
: shows a message asking the user to input text. It returns the text or, if CANCEL or `key:Esc` is clicked, `null`.
: 사용자에게 텍스트를 입력하라는 메시지를 표시합니다. 이 함수는 텍스트를 반환하거나, 취소(CANCEL) 또는 `key:Esc`를 누르면 `null`을 반환합니다.

`confirm`
: shows a message and waits for the user to press "OK" or "CANCEL". It returns `true` for OK and `false` for CANCEL/`key:Esc`.
: 메시지를 보여주고 사용자가 확인("OK")또는 취소("CANCEL")을 누를 때까지 기다립니다. 이 함수는 확인(OK)에 대해 `true`를 반환하고 CANCEL/`key:Esc`에 대해 `false`를 반환합니다.

All these methods are modal: they pause script execution and don't allow the visitor to interact with the rest of the page until the window has been dismissed.
이 모든 메서드는 모달입니다. 이 메서드들은 스크립트 실행을 일시 중지하고 방문자가 창을 닫을 때까지 나머지 페이지와 상호 작용할 수 없도록 합니다.

There are two limitations shared by all the methods above:
위의 메서드에는 공통된 두 가지 제한 사항이 있습니다.

1. The exact location of the modal window is determined by the browser. Usually, it's in the center.
2. The exact look of the window also depends on the browser. We can't modify it.
1. 모달 윈도우의 정확한 위치는 브라우저에 의해 결정됩니다. 대개 중앙에 있습니다.
2. 창의 모양은 브라우저에 따라 달라집니다. 우리는 그것을 수정할 수 없습니다.

That is the price for simplicity. There are other ways to show nicer windows and richer interaction with the visitor, but if "bells and whistles" do not matter much, these methods work just fine.
이 것은 간단함(simplicity)을 위해 치러야할 대가입니다. 더 좋은 창을 표시하고 방문자와 보다 풍부한 상호 작용을 보여주는 다른 방법이 있지만 "멋으로 덧붙이는 부가 기능"이 별로 중요하지 않은 경우, 이 메서드를 사용하는게 좋습니다.
Loading