Introduction
We use JavaScript objects to store data and retrieve it later. We store data(aka information) in key-value pairs. The key-v...
For further actions, you may consider blocking this person and/or reporting abuse
Nice π this is an amazing and very useful feature. Another useful thing with object destructing is to destruct some properties and then use the spread operator to get the rest.
Since it is ..., it's not sread operator.
In Object Destructuring, these three dots is rest propertises,
Rest in Object Destructuring
The Rest/Spread Properties for ECMAScript proposal (stage 4) adds the rest syntax to destructuring. Rest properties collect the remaining own enumerable property keys that are not already picked off by the destructuring pattern.
Awesome Daniel, Thanks for adding to the list. Have a great day.
I was playing a bit with at(), but it's not supported in all browsers.
Mindblowing. Thanks, John for sharing.
Here's one more for you.
Super. Thanks!
A lot of times, you don't need destructuring. Reasons:
You can use aliases for the # 1 point.
2, agree but when you see the entire dev ecosystem(like with React I see) using it, I think, it is better to contribute that way.
Hey, thanks a lot for giving it a read and posting your views.
I would advise against variable definitions during destructing like this:
What you're actually doing here is simply defining a default value for employee's property
message
. So as a side effect if your object actually has a property with that name, it will simply override your default value.It works, and you could still use it, but be aware of what's actually happening and consider writing 1 line of extra code to prevent possible unexpected behaviour.
Apart from that β A good overview to destructing. Gj!
Awesome article! I use destruction all the time. Two things I find confusing tho is that nesting and alias share the colon operator (if you look closely they differ in syntax but I find it confusing). Same with default value and assignment to new attribute. So if you want to create a new attribute you need to make sure that one does never already exist on the object or you might get unwanted results.
~Cheers
Thank you! I completly agree.
Great! Thanks for sharing.
Welcmome π
Hi just testing the comment indentation levels on dev.to
Test passed? π
I'm building a blog site and im in the process of adding nested replies to comments, I wanted to see how the ui here handled nested comments. I wonder how far down you can go and will it keep indenting
12
Thanks for elaborating destructuring in loops and and default value.π
It'll help me to improve my current project
That's great. Very glad to know, you found it helpful
Agree. The code needs to be human readable rather than concise. In any case the code gets compiled to a shorter form during build.
Awesome post
Thank you very much!