{
let a,b,rest
[a, b] = [1, 2]
console.log(a,b)
console.log('========')
}
{
let a, b, rest
[a,b,...rest] = [1,2,3,4,5,6,7]
console.log(a)
console.log(b)
console.log(rest)
console.log('========')
}
{
let a, b;
({a, b} = {a:1, b:2})
console.log(a)
console.log(b)
console.log('========')
}
{
let a, b, c, rest
[a, b, c, d=4] = [1, 2]
console.log(a)
console.log(b)
console.log(c)
console.log(d)
console.log('========')
}
{
let a = 1;
let b = 2;
[a, b] = [b, a];
console.log(a,b);
console.log('========');
}
{
function f(){
return [1, 2]
}
let a, b;
[a, b] = f();
console.log(a,b)
console.log('========');
}
{
function f() {
return [1, 2, 3, 4, 5]
}
let a,b,c;
[a,,,b] =f()
console.log(a,b)
console.log('========');
}
{
function f() {
return [1, 2, 3, 4, 5]
}
let a,b,c;
[a,...b] =f()
console.log(a)
console.log(b)
console.log('========');
}
console