标签:asc 赋值 java 分解 数组 rip 数值 fine 多个
ES6中允许从数组中提取值,按照对应位置,对变量赋值,对象也可以实现解构。【解构:分解数据结构。】
如果解构不成功,变量的值为undefined
let ary = [1, 2, 3];
let [a, b, c, d, e] = ary;
console.log(a); // 1
console.log(b); // 2
console.log(c); // 3
console.log(d); // undefined
console.log(e); // undefined
let person = { name: 'zhangsan', age: 20 };
let { name, age } = person;
console.log(name); // 'zhangsan'
console.log(age); // 20
let {name: myName, age: myAge} = person; // myName myAge 属于别名
console.log(myName); // 'zhangsan'
console.log(myAge); // 20
标签:asc 赋值 java 分解 数组 rip 数值 fine 多个
原文地址:https://www.cnblogs.com/jianjie/p/12236413.html