let [head,...tail]=[1,2,3,4];
// 如果解构不成功,变量的值就等于undefined。
let [a,b,...c]=['x'];
let [d,e,f]=new Set(['x','y','z'])
function*fibs(){
let a=0;
let b=1;
while(true){
yield a;
[a,b]=[b,a+b]
}
}
let [first, second, third, fourth, fifth, sixth] =fibs();
console.log(sixth);
function*ge(){
yield 1;
yield 2;
yield 3;
}
for(let g of ge()){
// console.log(g)
}
function h(){
// yield 1
console.log('aaa');
}
h()
let [i=h()]=[1]
console.log(i)
// j 是模式 没有被赋值
let {j:k=3}={};
// 遍历Map结构
let map=new Map();
map.set('first', 'hello');
map.set('second', 'world');
for(let [key,value] of map){
console.log(key + ' is '+value)
}
for(let [key] of map){
console.log(key)
}
for(let [,value] of map){
console.log(value)
}
console