数组解析赋值
let a = 1;
let b = 2;
let c = 3;
等同于
let [a, b, c] = [1, 2, 3];
默认值
let [a, b = "B"] = ["a", undefined...]
console.log(a, b)
当赋值为undefined的时候,默认值会生效
2.对象解析赋值
let { foo, bar } = { foo: 'A', bar: 'B' };
console.log...字符串解析赋值
const [a, b, c, d, e] = 'hello';
4....函数参数解析赋值
function add([x, y]){
return x + y;
}
console.log(add([1, 2])); // 3