destructing for javascript code example
Example 1: javascript function destructuring
function f() {
return [1, 2];
}
let a, b;
[a, b] = f();
console.log(a); // 1
console.log(b); // 2
Example 2: mdn destructuring
let a, b;
[a, b] = [1, 2];
console.log(a); // 1
console.log(b); // 2