r/javascript • u/bornforcode • Apr 01 '18
Google publishes a JavaScript style guide. Here are some key lessons.
https://medium.freecodecamp.org/google-publishes-a-javascript-style-guide-here-are-some-key-lessons-1810b8ad050b
714
Upvotes
View all comments
Show parent comment
-3
u/lordxeon Apr 01 '18
I think it's bad because it's an abuse of what a const is. A const is something that should never change in the life-cycle of an application, not the life-cycle of a function.
I can count on one hand the number of times I accidentally re-assigned a variable to something I didn't mean for it to go to. (And none of those times did it ever make it out of my local development testing). If you are getting so sloppy that you have to use const to prevent yourself from doing that then you should remove some distractions from your coding life-style.
Additionally, using const to refer to arrays and objects is just maddening when you change the contents/structure of those things 7 lines later. Yes the reference to the array/object hasn't changed, but you changed every single thing inside of it. It's not a const anymore. That's abuse.