Javascript

[Javascript] 구조 분해 할당

insub4067 2021. 7. 31. 11:26
const studentCountry = { kim: 'korea', Andy: 'USA' }

//구조분해할당을 사용안한 예
const KimsCountry = studentCountry.kim

//구조분해할당을 활용해서 변수명 재할당
const { kim : kimsCountry } = studentCountry

//구조분해할당만을 활용
const { kim } = studentCountry

//결과는 모두 같다
console.log(KimsCountry)
console.log(kimsCountry)
console.log(kim)