Last active
January 22, 2017 05:03
-
-
Save JasonCust/96ffc6b03c2f4f547e8471455b15734d to your computer and use it in GitHub Desktop.
ES2015 Destructuring Assignment Example -- Basic object destructuring assignment using a Dagwood Sandwich
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
let dagwoodSandwich = { | |
bread: 'rye', | |
cheeses: ['cheddar'], | |
meats: ['salami', 'ham', 'turkey', 'bologna'], | |
toppings: ['lettuce', 'tomatoes', 'onions', 'fried egg', 'olives'] | |
}; | |
let {bread, cheeses} = dagwoodSandwich; // <-- Destructuring Assignment | |
console.log({bread, cheeses}); // ouptut: { bread: 'rye', cheeses: ['cheddar'] } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment