I think the onus would be on you to prove that using a less restrictive concept is worthwhile because it saves you two keystrokes. That, in contrast, seems like the opposite of good engineering. Like using classes over structs because class is shorter to type.
The more I think about your post, the more absurd it becomes.
On the other hand, there are some good reasons not to use use const everywhere we can. Paul Sweeney lists a few here: https://medium.com/@PepsRyuu/use-let-by-default-not-const-58...
I'm not sure where I land yet. Perhaps it's a decision to make separately for each codebase.
const x = 1;
(function() {
const x = 2;
console.log(x);
})()
or from an argument: const x = 1;
(function(x) {
console.log(x);
})(2)
So it has limited value in any code that uses closures.If you've declared const x = 1, then that will hold for your scope?
If you go into a separate scope... Well, then you're in a separate scope?
In an ideal world, const would be the default, and you would have to opt into non-const.
> There has never been a bug caused by reassigning a function local variable while leaving it mutable.
The latter _is_ mutable state. const doesn't prevent all mutations, but it does prevent some, while let prevents none. I'll take the limited protections of const (with awareness of its limitations; many examples of let are of confused devs trying to avoid making their objects immutable).
The popular airbnb eslint rules[1] require the use of const where a variable is not reassigned, which I've occasionally found handy.
[1] https://github.com/airbnb/javascript#references--prefer-cons...