Skip to content

Instantly share code, notes, and snippets.

@JasonCust
Last active January 22, 2017 05:23
Show Gist options
  • Save JasonCust/6cbba19b48c9d92caab9d8b8e48fffc2 to your computer and use it in GitHub Desktop.
Save JasonCust/6cbba19b48c9d92caab9d8b8e48fffc2 to your computer and use it in GitHub Desktop.
ES2015 Destructuring Assignment Example -- Basic object destructuring assignment for arguments with defaults using a Dagwood Sandwich
function makeCheeseSandwich({bread, cheeses, condiments = ['mustard']}) {
return {bread, cheeses, condiments};
}
console.log(makeCheeseSandwich(dagwoodSandwich));
// output: { bread: 'rye', cheeses: [ 'cheddar' ], condiments: [ 'mustard' ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment