Created
August 30, 2019 10:56
-
-
Save skiabox/3607febe8f8bccffdb1440f852967467 to your computer and use it in GitHub Desktop.
ES6 Destructured Objects Parameters #ES6 #Javascript
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
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