2 ms·
> What's so wrong with var? var his function scoped, allows redeclarations in the same scope to work as reassignments, and has some other quirks, while let is
by dragonwriter 5y ago
> What's so wrong with var?
var his function scoped, allows redeclarations in the same scope to work as reassignments, and has some other quirks, while let is block scoped and errors on redeclarations in the same scope.
The net result is that var is a lot more trouble. If you are using ES6+ and need a reassignable variable, you should use let. If you need something that won’t be reassigned (even if it will be mutated), use const.