Skip to content

Instantly share code, notes, and snippets.

@JasonCust
Last active January 22, 2017 05:03
Show Gist options
  • Save JasonCust/96ffc6b03c2f4f547e8471455b15734d to your computer and use it in GitHub Desktop.
Save JasonCust/96ffc6b03c2f4f547e8471455b15734d to your computer and use it in GitHub Desktop.
ES2015 Destructuring Assignment Example -- Basic object destructuring assignment using a Dagwood Sandwich
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