r/node • u/craigtaub • Jun 17 '18
My most hated JavaScript features
https://medium.com/@tabu_craig/my-worst-javascript-features-465378d5ad43-4
u/kyranadept Jun 17 '18
Doing const { printName } = logger; is asking for it.
As for const myNewObj = myObj; myNewObj.hasGoatee = true;, this is worse than what the author suggests. Const is not const in JS; it should be used only for numbers.
9
u/Kollektiv Jun 17 '18
"const" means that the variable will not be reassigned and not that it won't mutate. Of course primitives don't mutate so numbers, booleans, strings, etc. have a higher guarantee.
3
u/mcaruso Jun 17 '18
constis a property of the variable, not the value it refers to. So the variable will always point to the same thing, even if the value itself changes.0
0
Jun 17 '18
[deleted]
1
u/pomlife Jun 18 '18
Yep, adequately handled. Unfortunately, the OPs of these ridiculous threads never seem to learn from this and will continue to agree with one another in circlejerky JS-hate threads.
3
u/PM_ME_A_WEBSITE_IDEA Jun 17 '18
I'm confused about the second last point about comparing objects. Any time you compare two objects, it's by memory address by my understanding. In what scenario would you need to do a deep compare? And in that case, how is that JavaScript's fault? Isn't that how most languages handle it? How else should it be handled?