Hacker News new | ask | show | jobs
by dmak 3997 days ago
What about it is not simple and consistent? Two different syntaxes, and two different expectations and rules. Var is function scope, and let is block scope.
1 comments

I feel like in a new design you would pick one or the other, as a second scoping rule would not carry its own weight in terms of what problems it solves vs the complexity of implementing runtimes or learning the language. In that case I'm almost certain you would go for block only as it is the default in nearly all curly braced languages.
Yes, as a matter of style you could just use let everywhere, and know that var is there for legacy compatibility reasons.
I think they have selected one over the other - let. var exists for compatibility, but there is zero reason to use it in new code.