구조분해할당(destructuring)
일반적인 선언
let arr = ["안", "정환"]
const firstName = arr[0]
const lastName = arr[1]
구조분해할당
let arr = ["안", "정환"]
let [firstName, lastName] = arr
배열 구조분해
배열의 순서대로 할당한다.
모든 이터러블 객체에 적용 가능하다.
객체 구조분해
let
let options = {
title: "Menu",
width: 100,
height: 200
};
let {title, width, height} = options;
객체의 키값과 이름이 동일한지를 기준으로 할당된다.