Skip to content

Commit fb7c165

Browse files
committed
[ko] merge all
Squashed commit of the following: commit 2ce9cfae13db7723d0def834bd1274daf88d71e3 Author: Changwoo Park <pismute@gmail.com> Date: Tue Oct 25 22:42:17 2011 +0900 [ko] correction commit 30f5d7b4d10fadec11327f5a5869bf13a0525865 Author: Changwoo Park <pismute@gmail.com> Date: Fri Oct 21 19:14:25 2011 +0900 [ko] types first draft ect commit 4f6cacb4af0b2251d6fdba78301e84262d10f2c1 Author: Changwoo Park <pismute@gmail.com> Date: Thu Oct 20 02:48:14 2011 +0900 [ko] first draft.
1 parent 66d98dd commit fb7c165

22 files changed

Lines changed: 491 additions & 919 deletions

‎doc/ko/array/constructor.md‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
## The `Array` Constructor
1+
## `Array` 생성자
22

3-
Since the `Array` constructor is ambiguous in how it deals with its parameters,
4-
it is highly recommended to always use the array literals - `[]` notation -
5-
when creating new arrays.
3+
`Array` 생성자가 파라미터를 처리하는 방법은 모호하기 때문에 항상 `[]` 노테이션으로 Array를 만들어야 한다.
64

75
[1, 2, 3]; // Result: [1, 2, 3]
86
new Array(1, 2, 3); // Result: [1, 2, 3]
@@ -11,25 +9,16 @@ when creating new arrays.
119
new Array(3); // Result: []
1210
new Array('3') // Result: ['3']
1311

14-
In cases when there is only one argument passed to the `Array` constructor
15-
and when that argument is a `Number`, the constructor will return a new *sparse*
16-
array with the `length` property set to the value of the argument. It should be
17-
noted that **only** the `length` property of the new array will be set this way;
18-
the actual indexes of the array will not be initialized.
12+
`Array` 생성자에 인자로 숫자 하나를 넘기면 생성자는 `length`가 그 숫자인 텅 빈 `Array` 하나를 반환한다. 생성자는 **오직** `length` 프로퍼티에 할당하기만 하고 실제 `Array`는 초기화하지 않는다는 것을 기억해야 한다.
1913

2014
var arr = new Array(3);
2115
arr[1]; // undefined
22-
1 in arr; // false, the index was not set
16+
1 in arr; // false, 이 인덱스는 초기화되지 않음.
2317

24-
The behavior of being able to set the length of the array upfront only comes in
25-
handy in a few cases, like repeating a string, in which it avoids the use of a
26-
`for loop` code.
18+
Array의 length 프로퍼티에 숫자를 할당해주는 이 기능이 유용할 때도 있긴 있다. `for loop`을 사용하지 않고 스트링을 더하는 경우가 그렇다.
2719

2820
new Array(count + 1).join(stringToRepeat);
2921

30-
### In Conclusion
31-
32-
The use of the `Array` constructor should be avoided as much as possible.
33-
Literals are definitely preferred. They are shorter and have a clearer syntax;
34-
therefore, they also increase the readability of the code.
22+
### 결론
3523

24+
`Array` 생성자는 가능하면 사용하지 말아야 한다. `[]` 노테이션이 더 알맞다. 더 간략하고 명확하기 때문에 보기도 좋다.

‎doc/ko/array/general.md‎

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,29 @@
1-
## Array Iteration and Properties
1+
## Array Iteration과 프로퍼티
22

3-
Although arrays in JavaScript are objects, there are no good reasons to use
4-
the [`for in loop`](#object.forinloop) in for iteration on them. In fact, there
5-
are a number of good reasons **against** the use of `for in` on arrays.
3+
JavaScript에서는 Array도 객체지만 Iterate를 할 때 [`for in`](#object.forinloop)을 사용해서 좋을 게 없다.
64

7-
> **Note:** JavaScript arrays are **not** *associative arrays*. JavaScript only
8-
> has [objects](#object.general) for mapping keys to values. And while associative
9-
> arrays **preserve** order, objects **do not**.
5+
> **Note:** JavaScript의 Array는 *Associative Array*가 **아니다**. JavaScript [객체](#object.general)는 key/value만 mapping 할 뿐이다. Associative Array는 순서를 보장하지만, 객체는 보장하지 않는다.
106
11-
Because the `for in` loop enumerates all the properties that are on the prototype
12-
chain and because the only way to exclude those properties is to use
13-
[`hasOwnProperty`](#object.hasownproperty), it is already up to **twenty times**
14-
slower than a normal `for` loop.
7+
`for in`은 프로토타입 체인에 있는 프로퍼티를 모두 훑는(enumerate) 데다가 객체 자신의 프로퍼티만 훑으려면 [`hasOwnProperty`](#object.hasownproperty)를 사용해야 하기 때문에 `for`보다 20배 느리다.
158

169
### Iteration
1710

18-
In order to achieve the best performance when iterating over arrays, it is best
19-
to use the classic `for` loop.
11+
Array를 Iterate 할 때에는 구식인 `for`를 사용하는 것이 가장 빠르다.
2012

2113
var list = [1, 2, 3, 4, 5, ...... 100000000];
2214
for(var i = 0, l = list.length; i < l; i++) {
2315
console.log(list[i]);
2416
}
2517

26-
There is one extra catch in the above example, which is the caching of the
27-
length of the array via `l = list.length`.
18+
위 예제에서 꼭 기억해야 하는 것은 `l = list.length`로 Array의 length 값을 캐시 했다는 것이다.
2819

29-
Although the `length` property is defined on the array itself, there is still an
30-
overhead for doing the lookup on each iteration of the loop. And while recent
31-
JavaScript engines **may** apply optimization in this case, there is no way of
32-
telling whether the code will run on one of these newer engines or not.
20+
Array에 있는 `length` 프로퍼티를 iterate마다 사용하는 것은 좀 부담스럽다. 최신 JavaScript 엔진은 이 일을 알아서 처리하기도 하지만 코드가 새 엔진에서 실행되도록 보장할 방법이 없다.
3321

34-
In fact, leaving out the caching may result in the loop being only **half as
35-
fast** as with the cached length.
22+
실제로 캐시 하지 않으면 성능이 반으로 줄어든다.
3623

37-
### The `length` Property
24+
### `length` 프로퍼티
3825

39-
While the *getter* of the `length` property simply returns the number of
40-
elements that are contained in the array, the *setter* can be used to
41-
**truncate** the array.
26+
`length` 프로퍼티의 *getter*는 단순히 Array 안에 있는 엘리먼트의 개수를 반환하고 *setter*는 할당한 수로 Array를 잘라 버린다.
4227

4328
var foo = [1, 2, 3, 4, 5, 6];
4429
foo.length = 3;
@@ -47,12 +32,8 @@ elements that are contained in the array, the *setter* can be used to
4732
foo.length = 6;
4833
foo; // [1, 2, 3]
4934

50-
Assigning a smaller length does truncate the array, but increasing the length
51-
does not have any effect on the array.
35+
현재 크기보다 더 작은 값을 할당하면 Array를 자르지만, 현재 크기보다 더 큰 값을 할당하면 아무것도 하지 않는다.
5236

53-
### In Conclusion
54-
55-
For the best performance, it is recommended to always use the plain `for` loop
56-
and cache the `length` property. The use of `for in` on an array is a sign of
57-
badly written code that is prone to bugs and bad performance.
37+
### 결론
5838

39+
최적의 성능을 위해서 `for`를 사용하고 `length` 프로퍼티 값을 캐시 하길 바란다. Array에 `for in`을 사용하면 성능도 떨어지고 버그 나기도 쉽다.

‎doc/ko/core/delete.md‎

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,56 @@
1-
## The `delete` Operator
1+
## `delete`
22

3-
In short, it's *impossible* to delete global variables, functions and some other
4-
stuff in JavaScript which have a `DontDelete` attribute set.
3+
간단히 말해서 global 변수, 함수, 등은 `DontDelete` 속성이기 때문에 삭제 못 한다.
54

6-
### Global code and Function code
5+
### 글로벌 코드와 함수 코드
76

8-
When a variable or a function is defined in a global
9-
or a [function scope](#function.scopes) it is a property of either
10-
Activation object or Global object. Such properties have a set of attributes,
11-
one of these is `DontDelete`. Variable and function declarations in global
12-
and function code always create properties with `DontDelete`, therefore
13-
cannot be deleted.
7+
Global이나 Function scope에 정의된 함수나 변수는 모두 Activation 객체나 Global 객체의 프로퍼티다. 이 프로퍼티는 모두 `DontDelete`속성을 가진다. Global이나 Function 코드에서 변수나 함수의 정의하면 항상 `DontDelete` 프로퍼티로 만들어진다. 그러니까 삭제할 수 없다:
148

15-
// global variable:
16-
var a = 1; // DontDelete is set
9+
// 글로벌 변수:
10+
var a = 1; // DontDelete가 설정된다.
1711
delete a; // false
1812
a; // 1
1913

20-
// normal function:
21-
function f() {} // DontDelete is set
14+
// 함수:
15+
function f() {} // DontDelete가 설정된다.
2216
delete f; // false
2317
typeof f; // "function"
2418

25-
// reassigning doesn't help:
19+
// 다시 할당해도 삭제할 수 없다:
2620
f = 1;
2721
delete f; // false
2822
f; // 1
2923

30-
### Explicit properties
24+
### Explicit 프로퍼티
3125

32-
There are things which can be deleted normally: these are explicitly set
33-
properties.
26+
다음 예제에서 만드는 property는 정상적으로 지워진다. 이런 걸 Explicit 프로퍼티라고 부른다:
3427

35-
// explicitly set property:
28+
// Explicit 프로퍼티를 만든다:
3629
var obj = {x: 1};
3730
obj.y = 2;
3831
delete obj.x; // true
3932
delete obj.y; // true
4033
obj.x; // undefined
4134
obj.y; // undefined
4235

43-
In the example above `obj.x` and `obj.y` can be deleted because they have no
44-
`DontDelete` atribute. That's why an example below works too.
36+
`obj.x`와 `obj.y`는 `DontDelete` 속성이 아녀서 삭제된다. 그러나 다음과 같은 코드도 잘 동작하기 때문에 헷갈린다.:
4537

46-
// this works fine, except for IE:
38+
// IE를 빼고 잘 동작한다.:
4739
var GLOBAL_OBJECT = this;
4840
GLOBAL_OBJECT.a = 1;
49-
a === GLOBAL_OBJECT.a; // true - just a global var
41+
a === GLOBAL_OBJECT.a; // true - 진짜 글로벌 변순지 확인하는 것
5042
delete GLOBAL_OBJECT.a; // true
5143
GLOBAL_OBJECT.a; // undefined
5244

53-
Here we use a trick to delete `a`. [`this`](#function.this) here refers
54-
to the Global object and we explicitly declare variable `a` as it's property
55-
which allows us to delete it.
45+
[`this`](#function.this)가 글로벌 객체를 가리키는 것을 이용해서 명시적으로 프로퍼티 `a`를 선언하면 삭제할 수 있다. 이런 꼼수가 가능하다.
5646

57-
IE (at least 6-8) has some bugs, so code above doesn't work.
47+
IE (적어도 6-8)는 버그가 있어서 안 된다.
5848

59-
### Function arguments and built-ins
49+
### arguments와 함수의 기본 프로퍼티
6050

61-
Functions' normal arguments, [`arguments` object](#function.arguments)
62-
and built-in properties also have `DontDelete` set.
51+
함수의 [`arguments` 객체](#function.arguments)와 built-in 프로퍼티도 `DontDelete` 속성이다.
6352

64-
// function arguments and properties:
53+
// 함수의 arguments와 프로퍼티:
6554
(function (x) {
6655

6756
delete arguments; // false
@@ -76,12 +65,12 @@ and built-in properties also have `DontDelete` set.
7665
7766
})(1);
7867

79-
### Host objects
80-
81-
Behaviour of `delete` operator can be unpredictable for hosted objects. Due to
82-
specification, host objects are allowed to implement any kind of behavior.
68+
### Host 객체
69+
70+
(역주, Host 객체들은 document같은 DOM 객체를 말한다.)
71+
72+
Host 객체를 delete하면 어떻게 될지 알 수 없다. 어떻게 Host 객체를 delete해야 하는지 표준에 정의되지 않았다.
8373

84-
### In conclusion
74+
### 결론
8575

86-
`delete` operator often has an unexpected behaviour and can be safely used
87-
only for dealing with explicitly set properties on normal objects.
76+
`delete` 연산자는 엉뚱하게 동작할 때가 잦다. 명시적으로 정의한 일반 객체의 프로퍼티만 delete하는 것이 안전하다.

‎doc/ko/core/eval.md‎

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Why Not to Use `eval`
1+
## 왜 `eval`을 사용하면 안 될까?
22

3-
The `eval` function will execute a string of JavaScript code in the local scope.
3+
`eval` 함수는 스트링으로 된 JavaScript 코드를 로컬 스콥에서 실행한다.
44

55
var foo = 1;
66
function test() {
@@ -11,8 +11,7 @@ The `eval` function will execute a string of JavaScript code in the local scope.
1111
test(); // 3
1212
foo; // 1
1313

14-
However, `eval` only executes in the local scope when it is being called
15-
**directly** *and* when the name of the called function is actually `eval`.
14+
`eval`을 `eval`이라는 이름으로 **직접** 직행할 때에만 로컬 스콥에서 실행된다.
1615

1716
var foo = 1;
1817
function test() {
@@ -24,24 +23,16 @@ However, `eval` only executes in the local scope when it is being called
2423
test(); // 2
2524
foo; // 3
2625

27-
The use of `eval` should be avoided at **all costs**. 99.9% of its "uses" can be
28-
achieved **without** it.
29-
30-
### `eval` in Disguise
26+
어쨌든 `eval`은 사용하지 말아야 한다. eval을 사용하는 경우의 99.9%는 사실 eval이 필요 없다.
3127

32-
The [timeout functions](#other.timeouts) `setTimeout` and `setInterval` can both
33-
take a string as their first argument. This string will **always** get executed
34-
in the global scope since `eval` is not being called directly in that case.
28+
### 가짜 `eval`
3529

36-
### Security Issues
30+
[timeout functions](#other.timeouts)인 `setTimeout`과 `setInterval`은 첫 번째 인자로 스트링을 입력받을 수 있다. 이 경우에는 `eval`을 직접 호출하는 것이 아녀서 항상 global scope에서 실행된다.
3731

38-
`eval` also is a security problem. Because it executes **any** code given to it,
39-
it should **never** be used with strings of unknown or untrusted origins.
32+
### 보안 이슈
4033

41-
### In Conclusion
34+
`eval`은 보안 문제도 있다. 단순히 **모든** 코드를 실행하기 때문에 신뢰하지 못하는 코드가 **절대로** 포함되지 않도록 주의해야 한다.
4235

43-
`eval` should never be used. Any code that makes use of it is to be questioned in
44-
its workings, performance and security. In case something requires `eval` in
45-
order to work, it should **not** be used in the first place.
46-
A *better design* should be used, that does not require the use of `eval`.
36+
### 결론
4737

38+
`eval`은 사용하지 않는 게 좋다. `eval`을 사용하는 모든 코드는 성능, 보안, 버그의 문제를 일으킬 수 있다. 만약 `eval`이 필요해지면 *설계를 변경*하여 `eval`이 필요 없게 만들어야 한다.

‎doc/ko/core/semicolon.md‎

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
## Automatic Semicolon Insertion
1+
## 세미콜론을 자동으로 삽입해준다.
22

3-
Although JavaScript has C style syntax, it does **not** enforce the use of
4-
semicolons in the source code, so it is possible to omit them.
3+
JavaScript는 C와 문법이 비슷하지만, 꼭 코드에 semicolon을 사용하도록 강제하지 않는다. 그래서 생략할 수 있다.
54

6-
JavaScript is not a semicolon-less language. In fact, it needs the
7-
semicolons in order to understand the source code. Therefore, the JavaScript
8-
parser **automatically** inserts them whenever it encounters a parse
9-
error due to a missing semicolon.
5+
사실 JavaScript는 semicolon이 꼭 있어야 하고 없으면 이해하지 못한다. 그래서 JavaScript 파서는 semicolon이 없으면 **자동으로** semicolon을 추가한다.
106

117
var foo = function() {
12-
} // parse error, semicolon expected
8+
} // 세미콜론이 없으니 에러 난다.
139
test()
1410

15-
Insertion happens, and the parser tries again.
11+
파서는 세미콜론을 삽입하고 다시 시도한다.
1612

1713
var foo = function() {
18-
}; // no error, parser continues
14+
}; // 에러가 없어짐.
1915
test()
2016

21-
The automatic insertion of semicolon is considered to be one of **biggest**
22-
design flaws in the language because it *can* change the behavior of code.
17+
JavaScript에서 세미콜론을 자동으로 삽입한 것은 **대표적인** 설계 오류 중 하나다. 세미콜론 유무에 따라 *전혀* 다른 코드가 될 수 있다.
2318

24-
### How it Works
19+
### 어떻게 다를까?
2520

26-
The code below has no semicolons in it, so it is up to the parser to decide where
27-
to insert them.
21+
코드에 세미콜론이 없으면 파서가 어디에 넣을지 결정한다.
2822

2923
(function(window, undefined) {
3024
function test(options) {
@@ -53,62 +47,53 @@ to insert them.
5347

5448
})(window)
5549

56-
Below is the result of the parser's "guessing" game.
50+
파서는 다음과 같이 삽입한다.
5751

5852
(function(window, undefined) {
5953
function test(options) {
6054

61-
// Not inserted, lines got merged
55+
// 세미콜론을 넣는 것이 아니라 줄을 합친다.
6256
log('testing!')(options.list || []).forEach(function(i) {
6357

64-
}); // <- inserted
58+
}); // <- 여기
6559

6660
options.value.test(
6761
'long string to pass here',
6862
'and another long string to pass'
69-
); // <- inserted
63+
); // <- 여기
7064

71-
return; // <- inserted, breaks the return statement
72-
{ // treated as a block
65+
return; // <- 여기에 넣어서 그냥 반환시킨다.
66+
{ // 파서는 단순 블럭이라고 생각하고
7367

74-
// a label and a single expression statement
68+
// 단순한 레이블과 함수
7569
foo: function() {}
76-
}; // <- inserted
70+
}; // <- 여기
7771
}
78-
window.test = test; // <- inserted
72+
window.test = test; // <- 여기
7973

80-
// The lines got merged again
74+
// 이 줄도 합쳐진다.
8175
})(window)(function(window) {
82-
window.someLibrary = {}; // <- inserted
76+
window.someLibrary = {}; // <- 여기
8377

84-
})(window); //<- inserted
78+
})(window); //<- 여기에 파서는 세미콜론을 넣는다.
8579

86-
> **Note:** The JavaScript parser does not "correctly" handle return statements
87-
> which are followed by a new line, while this is not neccessarily the fault of
88-
> the automatic semicolon insertion, it can still be an unwanted side-effect.
80+
> **주의:** JavaScript 파서는 new line 문자가 뒤따라 오는 return 구문을 제대로 처리하지 못한다. 자동으로 세미콜론을 넣는 것 자체의 문제는 아니지만 어쨌든 여전히 문제로 남아있다.
8981
90-
The parser drastically changed the behavior of the code above. In certain cases,
91-
it does the **wrong thing**.
82+
파서는 완전히 다른 코드로 만들어 버린다. 이것은 **오류**다.
9283

93-
### Leading Parenthesis
84+
### Parenthesis
9485

95-
In case of a leading parenthesis, the parser will **not** insert a semicolon.
86+
세미콜론 없이 괄호가 붙어 있으면 파서는 세미콜론을 넣지 않는다.
9687

9788
log('testing!')
9889
(options.list || []).forEach(function(i) {})
9990

100-
This code gets transformed into one line.
91+
파서는 다음과 같이 코드를 바꾼다.
10192

10293
log('testing!')(options.list || []).forEach(function(i) {})
10394

104-
Chances are **very** high that `log` does **not** return a function; therefore,
105-
the above will yield a `TypeError` stating that `undefined is not a function`.
95+
`log` 함수가 함수를 반환할 가능성은 거의 없다. 아마도 `undefined is not a function`이라는 `TypeError`가 발생할 거다.
10696

107-
### In Conclusion
108-
109-
It is highly recommended to **never** omit semicolons; it is also advocated to
110-
keep braces on the same line with their corresponding statements and to never omit
111-
them for one single-line `if` / `else` statements. Both of these measures will
112-
not only improve the consistency of the code, but they will also prevent the
113-
JavaScript parser from changing its behavior.
97+
### 결론
11498

99+
세미콜론은 반드시 사용해야 한다. 그리고 `{}`도 생략하지 않고 꼭 사용하는 것이 좋다. 한 줄밖에 안 되는 `if` / `else` 블럭에서도 꼭 사용해야 한다. 이 두 가지 규칙을 잘 지키면 JavaScript 파서가 잘못 해석하는 일을 미리 방지하고 코드도 튼튼해진다.

0 commit comments

Comments
 (0)