Skip to content

Instantly share code, notes, and snippets.

@skiabox
Created August 30, 2019 10:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skiabox/3607febe8f8bccffdb1440f852967467 to your computer and use it in GitHub Desktop.
Save skiabox/3607febe8f8bccffdb1440f852967467 to your computer and use it in GitHub Desktop.
ES6 Destructured Objects Parameters #ES6 #Javascript
function shipmentES6({ items = 'bananas', number = 5, package = 'boxes' } = {}) {
console.log(`We have a shipment of ${items} in ${number} ${package}.`);
};
shipmentES6({ package: 'crates' });
// -> We have a shipment of bananas in 5 crates.
shipmentES6({ items: 'tomatoes', number: 18 });
// -> We have a shipment of tomatoes in 18 boxes.
shipmentES6();
// -> We have a shipment of bananas in 5 boxes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment