Last active
January 22, 2017 05:05
-
-
Save JasonCust/bca445d13e2cca357572c7f079a447d2 to your computer and use it in GitHub Desktop.
ES2015 Destructuring Assignment Example -- Basic object destructuring assignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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