반응형
Notice
Recent Posts
Recent Comments
Link
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

taenyLog

[JavaScript] SPREAD (2) 배열 복사 본문

Web

[JavaScript] SPREAD (2) 배열 복사

taenyLog 2023. 9. 26. 10:14
반응형

In Array Literals 

Create a new array using an existing array. Spreads the elements from one array into a new array.

 

반복 가능한 객체를 어떻게 펼치는가 ? 

 

배열을 복사해서 쓴다.

const fruits = ['apple', 'banana'];
const vegetables = ['cucumber','lettuce','cabbage'];

const allGroceries = [...fruits, ...vagetabkes]

allGroceries 호출시 'apple', 'banana' , 'cucumber','lettuce','cabbage' 가 호출된다.

배열 두개를 묶어서 새로운 배열을 만들었다.

 

 

반응형