数组解构赋值 - Iterator接口
1、等号右边必须是数组结构或具有Iterator接口的数据结构
2、解构赋值允许设置默认值
3、根据数组元素的排序位置,不存在的 undefined
let [a, b, c, d] = [1,2,3] //d=undefined let [a, [b, c], d] = [1,[2,3],4] let [a, , , b] = [1,2,3,4] let [a, ...b] = [1,2,3,4] //a=1 b=[2,3,4] let [a, b, c] = new Set([1,2,3])
let [a=1] = [undefined] // a=1 let [a, b=1] = [1] // a=1 ,b=1 let [a=1, b=a] // a=1,b=1 let [a=b, b=2] // ReferenceErroe