DEV Community

Discussion on: 8 Ridiculously Simple Javascript Tricks Not Taught on Tutorials

Collapse
 
notngan profile image
Ngan B. Nguyen

May I ask what's the difference between { date: objDate } = obj vs. objDate = obj.date?

Collapse
 
veebuv profile image
Vaibhav Namburi

Literally nothing, its just a pattern some people use. I try not to always do destructed reassignment because it looks "messy" but sometimes I inherit projects where destructuring is used across the project and to stay consistent i keep with this pattern

Collapse
 
wimjongeneel profile image
Wim Jongeneel

There is one important difference: destruction shallowly clones the object. This is very important when considering referential transparency.

Thread Thread
 
veebuv profile image
Vaibhav Namburi

Would love for you to expand on this further. I agree with you and have a similar understanding however keen to know your views

Some comments have been hidden by the post's author - find out more