问题
With the new keyword let
for declaration of variables in javascript ES6, I can no longer think of good reasons to use var
. So far, I have been doing just that and I do not see any disadvantage of using let
ALL THE TIME.
What are good reasons to use var
today? Is it a good practice to use let
all the time today?
回答1:
IMO there is no definite advantage of using var
over let
, other than for its scope. One reason might be to support older browsers perhaps (if you don't plan to use an ES6 to ES5 compiler like Babel).
来源:https://stackoverflow.com/questions/41031342/what-are-some-reasons-to-use-var-instead-of-let-in-javascript