목록배열 (2)
taenyLog
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' 가 호출된다. 배열 두개를 묶어서 새로운 배열을 만들었다.
spread : 전개구문 배열과 같이 반복 가능한 객체를 전개 구문을 사용해서 확장한다. 함수로 호출할 경우엔 0개 이상의 인수로 배열 리터럴에서는 요소로 확장할 수 있다. 객체 리터럴의 경우 객체 표현식은 0개 이상 키-값 쌍으로 확장할 수 있다. The spread (...) syntax allows an iterable, such as an array or string, to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected. In an object literal, the spread syntax enumerates the propertie..