Y
Hacker News
new
|
ask
|
show
|
jobs
by
Polarity
1206 days ago
is it still common practice to use "var"?
4 comments
umvi
1206 days ago
I think "let" and "const" are preferable
link
hotz
1206 days ago
Doesn't const also get optimized better?
link
dgb23
1206 days 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.
link
Tade0
1206 days ago
No, but it's still useful in those rare instances in which you really need broader than block scoping.
link
rom-antics
1206 days 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.
link
edflsafoiewq
1206 days ago
No, var should never be used.
link
tuukkah
1206 days ago
... because var is function-scoped, not block-scoped like let.
link