Stop using “let” when you mean “const”
Using let when const is more correct is a misleading bad practice in JavaScript ES6.
Use “const” by default
When you first declare a symbol, use const. Assume your symbol’s identity will be immutable — that is, its value may not be reassigned. (Note that the value itself may be internally mutable. It’s just the identity or reference that is immutable.) If and only if you discover that reassignment is needed, then change const to let.
Use “let” as a last resort
If you find yourself using let more than const, you are probably doing too much mutation. Would your intent be expressed more clearly through constant algebraic symbols, whose values are predictable functions of other constant values? (See Redux for inspiration.) Sure, there are special situations that render this mathematical approach impossible. And that is why let exists: for special cases. let should jump off the page like a red flag. let should strike fear into your heart.
A “const” is worth a thousand “let”s
Unlike let, the const keyword provides useful information to someone reading your code. The const keyword asserts that (1) a symbol has been declared, and (2) its identity is immutable. The let keyword asserts only that a symbol has been declared — its identity is a mystery. It could point to anything.
Any symbol defined with const could also be defined with let. But it shouldn’t. That’s like saying, we could also just call every square a rectangle, and leave it at that. That may be the truth, but it’s far from the whole truth.
A final reminder
Before you go, please remember kids, every time you use var, a cute little kitten dies.* Happy coding!
* No kittens were harmed in the writing of this article.