Es 6 Destructuring assignment

Es 6 has new amazing feature Destructuring assignment. The destructuring assignment syntax is a JavaScript expression that makes it possible to extract data from arrays or objects into distinct variables.
var a, b, rest;
[a, b] = [1, 2];
console.log(a); // 1
console.log(b); // 2

({a, b} = {a:1, b:2});
console.log(a); // 1
console.log(b); // 2

Share this post