let [a,b,c] = [1,2,3]
console.log(a); // => 1
console.log(a,b,c); // =>1,2,3
注意:左右兩邊解構(gòu)格式要保持一致
舉例:
let json = {
name: ‘howe’
age: 23,
job: '碼農(nóng)'
}
//寫法01:
let {name,age,job} = json
console.log(name,age,job )
//寫法02:
let {name:a,age:b,job:c} = json
console.log(a,b,c )
//以上兩種寫法 打印結(jié)果一樣