구조 분해 할당
구조 분해 할당(destructuring assignment)은 구조화된 배열과 같은 이터러블 또는 객체를 비구조화하여 1개 이상의 변수에 개별적으로 할당하는 것을 말합니다. 배열 구조 분해 할당 const number = [1, 2, 3]; const [one, two, three] = number; console.log(one, two, three); // 1 2 3 변수 one, two, three를 선언하고 number를 구조 분해하여 할당합니다. 이 때 할당 기준은 배열의 인덱스입니다. const [a, b] = [1]; console.log(a, b) // 1 undefined const [c, , d] = [1, 2, 3]; console.log(c, d); // 1 3 const [e, ...
2023. 6. 16.