Array destructuring assignment ES6

It is very easy to assign the elements inside an array to any variable with the array destructuring assignment in ES6. Below code will sum up three elements together…

(function() {
let sum = [2,6,8];
let a,b,c;

[a, b, c] = sum;

console.log(a+b+c); //output 16


As you can see the variable a,b and c get the value from the sum’s array.