Destructuring is a convenient way of extracting multiple values from data stored in objects and Arrays. ES6 introduced some significant improvements to the language, including the de-structuring of Objects and Arrays. Honestly speaking, these are my favorite edition in the JavaScript standard syntax.
Let us take a look if we want to extract data from an array in es5.
Here, we are doing something quite boring stuff and repeated the same thing again and again. But ES6 destructuring assignment makes it easier.
We can also do this with the same result,
we can also declare variables before Assignment,
Assign variables a default value:
#destructuring #array-destructuring #javascript-destructuring #es6-destructuring #es6