HTML & CSS & JS/JS

[JS] 비구조할당

가자미 2021. 3. 17. 17:18
//비구조할당
const object = { a:1};
const {a, b=2}=object;

const array = [1];
const [one, two=2]=array;

const deepObject={
    state:{
        information:{
            name:'name',
            lang: ['korean', 'japan','china']
        }
    },
    value : 5
};
const {name, lang}=deepObject.state.information;
const {value}= deepObject;

const {
    state2:{
        information2:{
            name,lang2
        }
    },
    value
}=deepObject;