How to Jump Values in The Array Destructuring
To skip a value when using the array destructuring assignment syntax we just leave it blank and put a comma after it.
Here is an example of destructuring out the second and third values of an array.
const [,b,c] = [1, 2, 3, 4, 5];
console.log(b);
//2
console.log(c);
//3
Below is an example of extracting out only the third value of the array.
const [,,c] = ['A', 'B', 'C'];
console.log(c);
//'C'
Here is an example of destructuring out the third value from a comma-...
Published on April 15, 2021 03:04