DEV Community

loading...

Discussion on: Extract Functions Arguments using Destructure in JavaScript

Collapse
samanthaming profile image
Samantha Ming Author

Thanks Manolo! And glad you found it helpful!

Totally, passing object is super cool! which kinda acts like named parameters where you don't have to worry about the order. I believe this is what you're referring to:

// Boo, arguments must be in specific order
function meal(protein, carb, veggie){
}
meal('🥩', '🍚', '🥦')


// Yay, arguments can be in any order
function meal2({protein, carb, veggie}){
}
meal2({carb: '🍚', veggie: '🥦', protein: '🥩'})

I have a tidbit on it as well > samanthaming.com/tidbits/18-named-... 😊

Collapse
nombrekeff profile image
Keff

Yup that was exactly it :) I'll check it out