You could talk about default value as well 😁
Sure, default parameters work with object destructuring as well!
If the object passed to myFunc has no name property, the default value "Unknown" will be logged (instead of undefined) 👍
myFunc
name
"Unknown"
undefined
const myFunc = ({ name = "Unknown", age }) => { console.log(name, age); };
Thanks for your suggestion, I'll update the post!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You could talk about default value as well 😁
Sure, default parameters work with object destructuring as well!
If the object passed to
myFunc
has noname
property, the default value"Unknown"
will be logged (instead ofundefined
) 👍Thanks for your suggestion, I'll update the post!