1.起别名
data.forEach(
({ resourceAccessInfoCountVoList: list }, index) => {
if (list && list.length) {}
}
);
2.关于this
let { name,age,sex } = this; // 只能获取,不能进行操作(赋值),因为是值的赋值
3.嵌套对象的解构赋值
const obj = {
person: {
youngPeople: {
name: "luoting",
age: 18
},
oldPeople: {
name: "wangchen",
age: 28
}
}
};
const { person, person: { youngPeople: { name }, oldPeople: { age }}} = obj;
// 这里的第二个person是匹配的模式,不是变量,因此不会被赋值。
console.warn(person, name, age);