Skip to content

Instantly share code, notes, and snippets.

@JasonCust
Last active January 22, 2017 05:05
Show Gist options
  • Save JasonCust/bca445d13e2cca357572c7f079a447d2 to your computer and use it in GitHub Desktop.
Save JasonCust/bca445d13e2cca357572c7f079a447d2 to your computer and use it in GitHub Desktop.
ES2015 Destructuring Assignment Example -- Basic object destructuring assignment
/* ES5 equivalent
var obj = { one: 1, two: 2, three: 3 };
var one = obj.one;
var two = obj.two;
*/
let obj = { one: 1, two: 2, three: 3 };
let {one, two} = obj; // <-- Destructuring Assignment
console.log({one, two}); // output: { one: 1, two: 2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment