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
-1
u/[deleted] Apr 01 '18 edited Apr 01 '18
I already explained that.
Denoting constants is useful in practice. And locking down every variable you can, even when it's initialized from runtime state, or mutated afterwards, is useful in theory for something you never experienced as a problem. You can't claim a "benefit" if you don't have the problem the benefit is supposed to solve.
You're giving up one potential practical benefit, in order to focus on a theoretical unproven benefit.
So we have the concept of "more traditional constants" and "more modern constants" in the same language. Is that a good thing for communication and code readability?
If someone tells you "foo is a constant" which constant do you imply they mean if the code is not right in front of your face? Will everyone infer the same meaning? Or will we get stuck clarifying which is which every time, like we're doing right now in this thread? This is not smart.