Skip to content

Commit 6237a7a

Browse files
authored
Merge pull request #1857 from DevJunz/fix/devjunz-c12-conflict
[문서] C12 충돌 해결
1 parent 962a100 commit 6237a7a

8 files changed

Lines changed: 13 additions & 119 deletions

File tree

1-js/05-data-types/11-date/1-new-date/solution.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,18 @@
22

33
따라서 2월은 숫자 1을 사용해 만듭니다.
44

5-
Here's an example with numbers as date components:
6-
7-
Here's an example with numbers as date components:
5+
숫자로 날짜를 생성하는 예제는 다음과 같습니다.
86

97
```js run
108
//new Date(year, month, date, hour, minute, second, millisecond)
119
let d1 = new Date(2012, 1, 20, 3, 12);
1210
alert( d1 );
1311
```
14-
We could also create a date from a string, like this:
12+
13+
문자열로도 다음과 같이 날짜를 만들 수 있습니다.
1514

1615
```js run
1716
//new Date(datastring)
18-
<<<<<<< HEAD
19-
let d2 = new Date("February 20, 2012 03:12:00");
20-
=======
2117
let d2 = new Date("2012-02-20T03:12");
22-
>>>>>>> upstream/master
2318
alert( d2 );
2419
```

1-js/05-data-types/11-date/article.md

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,10 @@ Date 객체를 활용하면 생성 및 수정 시간을 저장하거나 시간
5757
`new Date(year, month, date, hours, minutes, seconds, ms)`
5858
: 주어진 인수를 조합해 만들 수 있는 날짜가 저장된 객체가 반환됩니다(지역 시간대 기준). 첫 번째와 두 번째 인수만 필수값입니다.
5959

60-
<<<<<<< HEAD
61-
- `year`는 반드시 네 자리 숫자여야 합니다. `2013`은 괜찮고 `98`은 괜찮지 않습니다.
60+
- `year`는 네 자리 숫자를 사용하는 것이 좋습니다. 호환성을 위해 두 자리 숫자도 허용되며 `19xx`로 간주합니다. 예를 들어 여기서 `98`은 `1998`과 같지만, 네 자리 숫자를 사용하는 것을 강력히 권장합니다.
6261
- `month`는 `0`(1월)부터 `11`(12월) 사이의 숫자여야 합니다.
6362
- `date`는 일을 나타내는데, 값이 없는 경우엔 1일로 처리됩니다.
6463
- `hours/minutes/seconds/ms`에 값이 없는 경우엔 `0`으로 처리됩니다.
65-
=======
66-
- The `year` should have 4 digits. For compatibility, 2 digits are also accepted and considered `19xx`, e.g. `98` is the same as `1998` here, but always using 4 digits is strongly encouraged.
67-
- The `month` count starts with `0` (Jan), up to `11` (Dec).
68-
- The `date` parameter is actually the day of month, if absent then `1` is assumed.
69-
- If `hours/minutes/seconds/ms` is absent, they are assumed to be equal `0`.
70-
>>>>>>> upstream/master
7164

7265
예시:
7366

@@ -76,11 +69,7 @@ Date 객체를 활용하면 생성 및 수정 시간을 저장하거나 시간
7669
new Date(2011, 0, 1); // hours를 비롯한 인수는 기본값이 0이므로 위와 동일
7770
```
7871

79-
<<<<<<< HEAD
8072
최소 정밀도는 1밀리초(1/1000초)입니다.
81-
=======
82-
The maximal precision is 1 ms (1/1000 sec):
83-
>>>>>>> upstream/master
8473

8574
```js run
8675
let date = new Date(2011, 0, 1, 2, 3, 4, 567);
@@ -359,11 +348,7 @@ let time1 = 0;
359348
let time2 = 0;
360349

361350
*!*
362-
<<<<<<< HEAD
363-
// 함수 bench를 각 함수(diffSubtract, diffGetTime)별로 10번씩 돌립니다.
364-
=======
365-
// run bench(diffSubtract) and bench(diffGetTime) each 10 times alternating
366-
>>>>>>> upstream/master
351+
// 함수 bench를 각 함수(diffSubtract, diffGetTime)별로 번갈아 가며 10번씩 돌립니다.
367352
for (let i = 0; i < 10; i++) {
368353
time1 += bench(diffSubtract);
369354
time2 += bench(diffGetTime);
@@ -391,11 +376,7 @@ for (let i = 0; i < 10; i++) {
391376
```warn header="세밀한 벤치마킹을 할 때는 주의하세요"
392377
모던 자바스크립트 엔진은 최적화를 많이 합니다. 이로 인해 '만들어진 테스트''실제 사례'와는 결과가 다를 수 있습니다. 특히 연산자, 내장 함수와 같이 아주 작은 것일수록 더 결과가 다를 수 있습니다. 그러니 진지하게 성능을 이해하고 싶다면 자바스크립트 엔진이 어떻게 동작하는지 공부하시길 바랍니다. 그러면 아마 세밀한 벤치마킹을 할 필요가 없을 겁니다.
393378

394-
<<<<<<< HEAD
395379
<http://mrale.ph>에서 V8 엔진을 설명한 좋은 글들을 보실 수 있습니다.
396-
=======
397-
The great pack of articles about V8 can be found at <https://mrale.ph>.
398-
>>>>>>> upstream/master
399380
```
400381
401382
## Date.parse와 문자열
@@ -404,17 +385,10 @@ The great pack of articles about V8 can be found at <https://mrale.ph>.
404385
405386
단, 문자열의 형식은 `YYYY-MM-DDTHH:mm:ss.sssZ`처럼 생겨야 합니다.
406387
407-
<<<<<<< HEAD
408388
- `YYYY-MM-DD` -- 날짜(연-월-일)
409389
- `"T"` -- 구분 기호로 쓰임
410390
- `HH:mm:ss.sss` -- 시:분:초.밀리초
411391
- `'Z'`(옵션) -- `+-hh:mm` 형식의 시간대를 나타냄. `Z` 한 글자인 경우엔 UTC+0을 나타냄
412-
=======
413-
- `YYYY-MM-DD` -- is the date: year-month-day.
414-
- The character `"T"` is used as the delimiter.
415-
- `HH:mm:ss.sss` -- is the time: hours, minutes, seconds and milliseconds.
416-
- The optional `'Z'` part denotes the time zone in the format `+-hh:mm`. A single letter `Z` would mean UTC+0.
417-
>>>>>>> upstream/master
418392
419393
`YYYY-MM-DD`, `YYYY-MM`, `YYYY`같이 더 짧은 문자열 형식도 가능합니다.
420394
@@ -450,17 +424,10 @@ alert(date);
450424
간혹 밀리초보다 더 정확한 시간 측정이 필요할 때가 있습니다. 자바스크립트는 마이크로초(1/1,000,000초)를 지원하진 않지만 대다수의 호스트 환경은 마이크로초를 지원합니다. 브라우저 환경의 메서드 [performance.now()](mdn:api/Performance/now)는 페이지 로딩에 걸리는 밀리초를 반환해주는데, 반환되는 숫자는 소수점 아래 세 자리까지 지원합니다.
451425
452426
```js run
453-
<<<<<<< HEAD
454427
alert(`페이지 로딩이 ${performance.now()}밀리초 전에 시작되었습니다.`);
455428
// 얼럿 창에 "페이지 로딩이 34731.26000000001밀리초 전에 시작되었습니다."와 유사한 메시지가 뜰 텐데
456429
// 여기서 '.26'은 마이크로초(260마이크로초)를 나타냅니다.
457430
// 소수점 아래 숫자 세 개 이후의 숫자는 정밀도 에러때문에 보이는 숫자이므로 소수점 아래 숫자 세 개만 유효합니다.
458-
=======
459-
alert(`Loading started ${performance.now()}ms ago`);
460-
// Something like: "Loading started 34731.26000000001ms ago"
461-
// .26 is microseconds (260 microseconds)
462-
// more than 3 digits after the decimal point are precision errors, only the first 3 are correct
463-
>>>>>>> upstream/master
464431
```
465432
466433
Node.js에선 `microtime` 모듈 등을 사용해 마이크로초를 사용할 수 있습니다. 자바스크립트가 구동되는 대다수의 호스트 환경과 기기에서 마이크로초를 지원하고 있는데 `Date` 객체만 마이크로초를 지원하지 않습니다.

1-js/05-data-types/12-json/article.md

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ alert(user); // {name: "John", age: 30}
2727

2828
## JSON.stringify
2929

30-
<<<<<<< HEAD
3130
[JSON](http://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation)은 값이나 객체를 나타내주는 범용 포맷으로, [RFC 4627](http://tools.ietf.org/html/rfc4627) 표준에 정의되어 있습니다. JSON은 본래 자바스크립트에서 사용할 목적으로 만들어진 포맷입니다. 그런데 라이브러리를 사용하면 자바스크립트가 아닌 언어에서도 JSON을 충분히 다룰 수 있어서, JSON을 데이터 교환 목적으로 사용하는 경우가 많습니다. 특히 클라이언트 측 언어가 자바스크립트일 때 말이죠. 서버 측 언어는 무엇이든 상관없습니다.
32-
=======
33-
The [JSON](https://en.wikipedia.org/wiki/JSON) (JavaScript Object Notation) is a general format to represent values and objects. It is described as in [RFC 4627](https://tools.ietf.org/html/rfc4627) standard. Initially it was made for JavaScript, but many other languages have libraries to handle it as well. So it's easy to use JSON for data exchange when the client uses JavaScript and the server is written on Ruby/PHP/Java/Whatever.
34-
>>>>>>> upstream/master
3531

3632
자바스크립트가 제공하는 JSON 관련 메서드는 아래와 같습니다.
3733

@@ -108,15 +104,9 @@ JSON은 데이터 교환을 목적으로 만들어진 언어에 종속되지 않
108104

109105
`JSON.stringify` 호출 시 무시되는 프로퍼티는 아래와 같습니다.
110106

111-
<<<<<<< HEAD
112107
- 함수 프로퍼티 (메서드)
113108
- 심볼형 프로퍼티 (키가 심볼인 프로퍼티)
114109
- 값이 `undefined`인 프로퍼티
115-
=======
116-
- Function properties (methods).
117-
- Symbolic keys and values.
118-
- Properties that store `undefined`.
119-
>>>>>>> upstream/master
120110

121111
```js run
122112
let user = {
@@ -338,13 +328,9 @@ alert(JSON.stringify(user, null, 2));
338328
*/
339329
```
340330

341-
<<<<<<< HEAD
342-
이처럼 매개변수 `space`는 로깅이나 가독성을 높이는 목적으로 사용됩니다.
343-
=======
344-
The third argument can also be a string. In this case, the string is used for indentation instead of a number of spaces.
331+
세 번째 인수로 문자열을 전달할 수도 있습니다. 이 경우 공백 개수 대신 해당 문자열이 들여쓰기에 사용됩니다.
345332

346-
The `space` parameter is used solely for logging and nice-output purposes.
347-
>>>>>>> upstream/master
333+
이처럼 매개변수 `space`는 로깅이나 가독성을 높이는 목적으로 사용됩니다.
348334

349335
## 커스텀 "toJSON"
350336

@@ -464,11 +450,7 @@ let json = `{
464450

465451
JSON은 주석을 지원하지 않는다는 점도 기억해 놓으시기 바랍니다. 주석을 추가하면 유효하지 않은 형식이 됩니다.
466452

467-
<<<<<<< HEAD
468453
키를 큰따옴표로 감싸지 않아도 되고 주석도 지원해주는 [JSON5](http://json5.org/)라는 포맷도 있는데, 이 포맷은 자바스크립트 명세서에서 정의하지 않은 독자적인 라이브러리입니다.
469-
=======
470-
There's another format named [JSON5](https://json5.org/), which allows unquoted keys, comments etc. But this is a standalone library, not in the specification of the language.
471-
>>>>>>> upstream/master
472454

473455
JSON 포맷이 까다로운 규칙을 가지게 된 이유는 개발자의 귀차니즘 때문이 아니고, 쉽고 빠르며 신뢰할 수 있을 만한 파싱 알고리즘을 구현하기 위해서입니다.
474456

1-js/06-advanced-functions/01-recursion/01-sum-to/solution.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,4 @@ alert( sumTo(100) );
3737

3838
반복을 사용하는 방법은 두 번째로 빠릅니다. 재귀를 사용하는 방법과 반복문을 사용하는 방법 모두 같은 수의 숫자를 더하는 것에서 같지만, 재귀를 사용하는 방법은 중첩 호출과 실행 스택 관리가 추가로 필요하기 때문에 더 많은 자원을 소비합니다. 따라서 속도가 더 느리죠.
3939

40-
<<<<<<< HEAD
4140
더 생각해보기 2: 몇몇 자바스크립트 엔진은 'tail call' 최적화를 지원합니다. 위 함수 `sumTo`처럼 함수가 가장 마지막으로 수행하는 연산이 재귀 호출이라면 외부 함수는 실행을 다시 시작할 필요가 없기 때문에 엔진은 실행 컨텍스트를 기억할 필요가 없어집니다. 메모리 부담이 사라지는 거죠. 그렇기 때문에 `sumTo(100000)`같은 계산이 가능한 것입니다. 그런데 자바스크립트 엔진이 tail call 최적화를 지원하지 않는다면(대부분의 엔진이 이를 지원하지 않습니다) 엔진에 설정된 스택 사이즈 제한을 넘었기 때문에 최대 스택 사이즈 초과 에러가 발생합니다.
42-
=======
43-
P.P.S. Some engines support the "tail call" optimization: if a recursive call is the very last one in the function, with no other calculations performed, then the outer function will not need to resume the execution, so the engine doesn't need to remember its execution context. That removes the burden on memory. But if the JavaScript engine does not support tail call optimization (most of them don't), there will be an error: maximum stack size exceeded, because there's usually a limitation on the total stack size.
44-
>>>>>>> upstream/master

1-js/06-advanced-functions/01-recursion/02-factorial/solution.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
<<<<<<< HEAD
21
팩토리얼은 그 정의에 따라 `n!``n * (n-1)!`로 바꿔쓸 수 있습니다.
3-
=======
4-
By definition, a factorial `n!` can be written as `n * (n-1)!`.
5-
>>>>>>> upstream/master
62

73
따라서 `factorial(n)`의 결과는 `n``factorial(n-1)`의 결과를 곱한 값이 되겠죠. 함수의 인수는 `n-1`에서 `1`이 될 때까지 점점 줄어들 겁니다.
84

1-js/06-advanced-functions/01-recursion/05-output-single-linked-list-reverse/solution.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ printReverseList(list);
3333

3434
# 반복문을 기반으로 하는 방법
3535

36-
<<<<<<< HEAD
37-
리스트를 원래 순서대로 출력하는 방법보다 역시 까다롭습니다.
38-
=======
39-
The loop variant is also a little bit more complicated than the direct output.
40-
>>>>>>> upstream/master
36+
반복문을 기반으로 하는 방법도 직접 출력하는 방법보다 조금 더 복잡합니다.
4137

4238
`list`의 마지막 값을 바로 구할 수 있는 방법이 없기 때문입니다. 마지막 값을 시작으로 '역행'할 수 없는 상황이죠.
4339

1-js/06-advanced-functions/01-recursion/article.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,7 @@ function pow(x, n) {
132132
</li>
133133
</ul>
134134

135-
<<<<<<< HEAD
136135
위 그림은 함수 실행이 시작되는 순간을 나타낸 것입니다. 지금 상태론 조건 `n == 1`을 만족하지 못하므로 실행 흐름은 `if`의 두 번째 분기로 넘어갑니다.
137-
=======
138-
That's when the function starts to execute. The condition `n == 1` is falsy, so the flow continues into the second branch of `if`:
139-
>>>>>>> upstream/master
140136

141137
```js run
142138
function pow(x, n) {
@@ -192,11 +188,7 @@ alert( pow(2, 3) );
192188
이전 컨텍스트에 변수 정보, 코드가 일시 중단된 줄에 대한 정보가 저장되어있기 때문에 서브 호출이 끝났을 때 이전 컨텍스트가 문제없이 다시 시작됩니다.
193189

194190
```smart
195-
<<<<<<< HEAD
196191
예시엔 한 줄에 서브 호출 하나만 있기 때문에, 그림에서 '줄'이라는 단어를 사용했습니다. 하지만 한 줄에는 `pow(…) + pow(…) + somethingElse(…)` 같이 복수의 서브 호출이 있을 수 있습니다.
197-
=======
198-
Here in the picture we use the word "line", as in our example there's only one subcall in line, but generally a single line of code may contain multiple subcalls, like `pow(…) + pow(…) + somethingElse(…)`.
199-
>>>>>>> upstream/master
200192
201193
따라서 좀 더 정확히는 실행이 '서브 호출 바로 직후'에 시작된다고 이야기 할 수 있습니다.
202194
```
@@ -293,11 +285,7 @@ function pow(x, n) {
293285

294286
**재귀를 이용해 작성한 코드는 반복문을 사용한 코드로 다시 작성할 수 있습니다. 반복문을 사용하면 대개 함수 호출의 비용(메모리 사용)이 절약됩니다.**
295287

296-
<<<<<<< HEAD
297288
하지만 코드를 다시 작성해도 큰 개선이 없는 경우가 있습니다. 조건에 따라 함수가 다른 재귀 서브 호출을 하고 그 결과를 합칠 때가 그렇습니다. 분기문이 복잡하게 얽혀있을 때도 메모리가 크게 절약되지 않습니다. 이런 경우엔 최적화가 필요하지 않을 수 있고 최적화에 드는 노력이 무용지물일 수 있습니다.
298-
=======
299-
...But sometimes the rewrite is non-trivial, especially when a function uses different recursive subcalls depending on conditions and merges their results or when the branching is more intricate. And the optimization may be unneeded and totally not worth the efforts.
300-
>>>>>>> upstream/master
301289

302290
재귀를 사용하면 코드가 짧아지고 코드 이해도가 높아지며 유지보수에도 이점이 있습니다. 모든 곳에서 메모리 최적화를 신경 써서 코드를 작성해야 하는 것은 아닙니다. 우리가 필요한 것은 좋은 코드입니다. 이런 이유 때문에 재귀를 사용합니다.
303291

@@ -547,11 +535,7 @@ list.next = list.next.next;
547535
list = {value, next -> list}
548536
```
549537

550-
<<<<<<< HEAD
551538
HTML 문서의 HTML 요소 트리나 위에서 다룬 부서를 나타내는 트리 역시 재귀적인 자료 구조로 만들었습니다. 이렇게 재귀적인 자료 구조를 사용하면 가지가 여러 개인데 각 가지가 여러 가지로 뻗쳐 나가는 형태로 자료 구조를 만들 수 있습니다.
552-
=======
553-
Trees like HTML elements tree or the department tree from this chapter are also naturally recursive: they have branches and every branch can have other branches.
554-
>>>>>>> upstream/master
555539

556540
예시에서 구현한 `sumSalary`같은 재귀 함수를 사용하면 각 분기(가지)를 순회할 수 있습니다.
557541

1-js/06-advanced-functions/02-rest-parameters-spread/article.md

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ function sum(a, b) {
2323
alert( sum(1, 2, 3, 4, 5) );
2424
```
2525

26-
<<<<<<< HEAD
27-
함수를 정의할 땐 인수를 두 개만 받도록 하고, 실제 함수를 호출할 땐 이보다 더 많은 '여분의' 인수를 전달했지만, 에러가 발생하지 않았습니다. 다만 반환 값은 처음 두 개의 인수만을 사용해 계산됩니다.
28-
=======
29-
There will be no error because of "excessive" arguments. But of course in the result only the first two will be counted, so the result in the code above is `3`.
30-
>>>>>>> upstream/master
26+
함수를 정의할 땐 인수를 두 개만 받도록 하고, 실제 함수를 호출할 땐 이보다 더 많은 '여분의' 인수를 전달했지만, 에러가 발생하지 않았습니다. 다만 결과를 계산할 때는 처음 두 개의 인수만 사용하므로 위 코드의 결과는 `3`이 됩니다.
3127

3228
이렇게 여분의 매개변수는 그 값들을 담을 배열 이름을 마침표 세 개 `...`뒤에 붙여주면 함수 선언부에 포함시킬 수 있습니다. 이때 마침표 세 개 `...`는 "남아있는 매개변수들을 한데 모아 배열에 집어넣어라."는 것을 의미합니다.
3329

@@ -229,28 +225,19 @@ alert( Array.from(str) ); // H,e,l,l,o
229225
이런 이유때문에 무언가를 배열로 바꿀 때는 전개 구문보다 `Array.from`이 보편적으로 사용됩니다.
230226
231227
232-
<<<<<<< HEAD
233228
## 배열과 객체의 복사본 만들기
234-
=======
235-
## Copy an array/object
236-
>>>>>>> upstream/master
237229
238230
[참조에 의한 객체 복사](info:object-copy#cloning-and-merging-object-assign) 챕터에서 `Object.assign()`을 사용해 객체를 복사한 예시를 떠올려봅시다.
239231
240232
`Object.assign()` 말고도 스프레드 문법을 사용하면 배열과 객체를 복사할 수 있습니다.
241233
242234
```js run
243235
let arr = [1, 2, 3];
244-
<<<<<<< HEAD
245-
let arrCopy = [...arr]; // 배열을 펼쳐서 각 요소를 분리후, 매개변수 목록으로 만든 다음에
246-
// 매개변수 목록을 새로운 배열에 할당함
247-
=======
248236
249237
*!*
250-
let arrCopy = [...arr]; // spread the array into a list of parameters
251-
// then put the result into a new array
238+
let arrCopy = [...arr]; // 배열을 펼쳐서 각 요소를 분리한 후, 매개변수 목록으로 만든 다음에
239+
// 매개변수 목록을 새로운 배열에 할당함
252240
*/!*
253-
>>>>>>> upstream/master
254241
255242
// 배열 복사본의 요소가 기존 배열 요소와 진짜 같을까요?
256243
alert(JSON.stringify(arr) === JSON.stringify(arrCopy)); // true
@@ -268,16 +255,11 @@ alert(arrCopy); // 1, 2, 3
268255
269256
```js run
270257
let obj = { a: 1, b: 2, c: 3 };
271-
<<<<<<< HEAD
272-
let objCopy = { ...obj }; // 객체를 펼쳐서 각 요소를 분리후, 매개변수 목록으로 만든 다음에
273-
// 매개변수 목록을 새로운 객체에 할당함
274-
=======
275258
276259
*!*
277-
let objCopy = { ...obj }; // spread the object into a list of parameters
278-
// then return the result in a new object
260+
let objCopy = { ...obj }; // 객체를 펼쳐서 각 요소를 분리한 후, 매개변수 목록으로 만든 다음에
261+
// 매개변수 목록을 새로운 객체에 할당함
279262
*/!*
280-
>>>>>>> upstream/master
281263
282264
// 객체 복사본의 프로퍼티들이 기존 객체의 프로퍼티들과 진짜 같을까요?
283265
alert(JSON.stringify(obj) === JSON.stringify(objCopy)); // true
@@ -291,11 +273,7 @@ alert(JSON.stringify(obj)); // {"a":1,"b":2,"c":3,"d":4}
291273
alert(JSON.stringify(objCopy)); // {"a":1,"b":2,"c":3}
292274
```
293275
294-
<<<<<<< HEAD
295276
이렇게 전개 구문을 사용하면 `let objCopy = Object.assign({}, obj);`, `let arrCopy = Object.assign([], arr);`보다 더 짧은 코드로 배열이나 객체를 복사할 수 있어서 사람들은 이 방법을 선호합니다.
296-
=======
297-
This way of copying an object is much shorter than `let objCopy = Object.assign({}, obj)` or for an array `let arrCopy = Object.assign([], arr)` so we prefer to use it whenever we can.
298-
>>>>>>> upstream/master
299277
300278
301279
## 요약

0 commit comments

Comments
 (0)