A question for my elders in JavaScript: putting aside the fact that let
has a different variable scope than var
does, it seems to me that in the vast majority of cases, there is no reason to use var
over let
. Of course, if you define a variable inside of an if
statement, it's not the same thing, but is there another reason besides scope to use one over the other?
Edit: To be clear, this question is about a best practice (i.e. pros and cons) in JavaScript, not about the nature of the differences between var
and let
.
Thanks!