Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
Polarity
· 3y ago · 0 comments
is it still common practice to use "var"?
Comments
[–]
umvi
3y ago
I think "let" and "const" are preferable
[–]
hotz
3y ago
Doesn't const also get optimized better?
[–]
dgb23
3y ago
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.
[–]
Tade0
3y ago
No, but it's still useful in those rare instances in which you really need broader than block scoping.
[–]
rom-antics
3y ago
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.
[–]
edflsafoiewq
3y ago
No, var should never be used.
[–]
tuukkah
3y ago
... because var is function-scoped, not block-scoped like let.