const obj = {name: "孙悟空", age: 18, gender: "男"};
let {name, age, gender} = obj; // 声明变量同时解构变量
console.log(name, age, gender); // 孙悟空 18 男
let {name:a, age:b, gender:c, address:d="花果山"} = obj; // name起别名为a, address:d="花果山":起别名并赋默认值
console.log(a, b, c, d); // 孙悟空 18 男 花果山
标签:obj,name,gender,age,JavaScript,笔记,解构,18
From: https://www.cnblogs.com/zibocoder/p/17067185.html