Hacker News new | ask | show | jobs
by Polarity 1206 days ago
is it still common practice to use "var"?
4 comments

I think "let" and "const" are preferable
Doesn't const also get optimized better?
I don’t see a good reason to use it. When I want to change a value later I use let at the top of the appropriate block, otherwise const. The code reads nicer that way.
No, but it's still useful in those rare instances in which you really need broader than block scoping.
Even then I still think it's clearer to put a `let` in the outer scope instead of putting a `var` in one of the inner scopes.
No, var should never be used.
... because var is function-scoped, not block-scoped like let.