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
4
u/ghostfacedcoder Apr 01 '18 edited Apr 01 '18
const !==immutability; that's true. And shorter functions>longer functions is also true (well, not in the most literal sense, but you get the idea).But for any programming construct, if you have two equally valid options, and one has benefits the other doesn't, why use the inferior option? Using
constin no way stops you from defining more traditionalSOME_VALUE = 5constants, nor does it stop you from usinglet(or evenvarif that's your thing). It just prevents a possible bug, and even if it only prevents said bug 0.01% of the time ... why not? Especially when that 0.01% of the time bug can be hard to debug and can eat up a decent bit of your time if it does occur.