> Defaulting to const does nothing. If you or someone else decides later that it should be reassignable, then they'll change it and not think about it.
Which they'll do regardless. `const` is an indication that the binding is not updated in the rest of the scope and thus that said scope can be perused without needing to consider an update to the binding itself. It is a guarantee of SSA, nothing more and nothing less.
> If const is rare in your code, people will be aware of what const means in that context.
The same as above which you apparently assert is "nothing"?
> If you're putting your variable declarations after your return statement
Why would I do that? I'm not adamantly using `var` when I have no reason to.
If everything is a constant then nothing is a constant.
Code bases change and some things that a coder did not foresee needing to be reassignable may later need to be reassignable. There aren't frequent cases that switching them becomes a problem, and as a result, people switch them. Since they do get switched so often, people stop thinking about when it really matters or if there was some intent to it originally being written that way. If everything is a constant, then the cases where it matters and the cases where it doesn't get blended together and it's impossible to differentiate the two.
When real, true constants are the only things declared with const, then it's abundantly clear what the intention of the coder was and that the value should never be changed nor should it ever be switched over to let/var.
Likewise with let, in the few cases where it's used it draws others' attention to the use of block scoping or the avoidance of hoisting. It's rare that those things really come into play, so the few cases where it's present really stand out.
tl;dr Block scoping and constants are the exception, not the DEFAULT, so you should write code accordingly.
> If you're putting your variable declarations after your return statement
What I meant here is that people shouldn't keep using var just so they can continue writing bad code.
> There aren't frequent cases […] Since they do get switched so often
They don't. In fact they almost never do.
> tl;dr Block scoping and constants are the exception
That's literally the opposite of reality. Constant bindings (single-assignment) and block-scoped bindings are by far the most common state of affairs even if not formally stated.
> What I meant here is that people shouldn't keep using var just so they can continue writing bad code.
Maybe you should tell the you of two comments ago who's apparently arguing for exactly that?
What's with the hostility? I'm just trying to express my opinion. You can disagree and state your point without being insulting.
Sure, when I say frequent, I don't mean its happening all the time all over the place, I just means it can and does happen without consequence. Block scoping and constants, in the sense that it's important that they're block scoped and constant, are the exception. Most variables are single-assignment not out of necessity. And I bet most people think in function scope, regardless of how the compiler works.
It all still comes down to intent. If you're always defaulting to using const, your intention is not really showing through.
Which they'll do regardless. `const` is an indication that the binding is not updated in the rest of the scope and thus that said scope can be perused without needing to consider an update to the binding itself. It is a guarantee of SSA, nothing more and nothing less.
> If const is rare in your code, people will be aware of what const means in that context.
The same as above which you apparently assert is "nothing"?
> If you're putting your variable declarations after your return statement
Why would I do that? I'm not adamantly using `var` when I have no reason to.