destructure object from array code example
Example 1: destructure array javascript
var [first, second, ...rest] = ["Mercury", "Earth", ...planets, "Saturn"];
Example 2: array destructuring
const myArray = ["a", "b", "c"];
const x = myArray[0];
const y = myArray[1];
console.log(x, y);
const myArray = ["a", "b", "c"];
const [x, y] = myArray;
console.log(x, y);
Example 3: javascript destructing
const x = [1, 2, 3, 4, 5]
const [a, b] = x
console.log(a)
console.log(b)
Example 4: destructure to object
({x: oof.x, y: oof.y} = foo);