Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.