[JavaScript] 구조 분해 할당 구문
오늘은 구조 분해 할당 구문에 대해서 공부했다. 구조 분해 할당 구문은 배열이나 객체의 속성을 해체하여 그 값을 개별 변수에 담을 수 있게 하는 표현식이다. // 변수 값 서로 교환하기 let a = 1; let b = 3; [a, b] = [b, a]; console.log(a); // 3 console.log(b); // 1 const arr = ['one', 'two', 'three', 'four'] const [first, second] = arr // 각 변수에 array 배열의 원소 값 대입 console.log(first, second) // one two // 전개 문법을 배열 분해에 적용 가능 const arr = ['one', 'two', 'three', 'four'] const [st..
2020. 10. 20.