Skip to content

Commit e7b5797

Browse files
committed
advanced-functions/rest-parameters-spread 아티클 충돌 해결
1 parent 3c8363c commit e7b5797

1 file changed

Lines changed: 5 additions & 27 deletions

File tree

  • 1-js/06-advanced-functions/02-rest-parameters-spread

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)