Array Destructuring in JavaScript

[var1,var2,var3] = array

image of javascript

Let us Understand the use of array destructuring in ES6

In ES5 if the array elements were to be named with a variable instead of accessing them with their index we were supposed to initialize them with variable

Let us take an Example

like this, we were supposed to access the array elements but with array destructuring, this can be skipped

What if we don't want to assign variables to all the array elements in such case what can be done

EXERCISE — — — — — — — — — — — — — — —

SWAP TWO NUMBERS WITHOUT USING A TEMPORARY VARIABLE