let node = {
personalInfo: {
basicInfo: {
name: 'mike',
age: 25
}
},
level: 3
};
// 属性重命名+默认值
let { personalInfo: { basicInfo: { name, age: myAge, country:nation='china' } } } = node;
console.log(name);// 'mike'
console.log(age);// Error: age is not defined
console.log(myAge);// 25
console.log(country);// Error: country is not defined
console.log(nation);// 'china'
【ES6】嵌套对象解构-多次解构
最新推荐文章于 2024-11-13 16:57:55 发布