destructure object inside array code example
Example 1: destructure array javascript
var [first, second, ...rest] = ["Mercury", "Earth", ...planets, "Saturn"];
Example 2: javascript nested array destructuring
let arr = [1, 2, 3, 4, [100, 200, 300], 5, 6, 7];
const [a, , , , [, b, ,], , , ,] = arr;
console.log(a);
console.log(b);
Example 3: array destructuring in javascript
const array = ['ismail', 'sulman'];
const [firstElement, secondElement] = array;
console.log(firstElement, secondElement);
const secondArray = ['ismail', 'naeem', 'Mr', 1];
const [firstEl, secondEl, ...array1] = secondArray;
console.log(firstEl, secondEl, array1);