var
is an issue because var
is hoisted.var
is function scope, let
is block scope.let
is the new var
.const
is a constant. it is for something that is only going to be defined once. You can not redefine const
.const
is not exactly immutable, the values in const
can sometimes be changed, for example if it’s an object and you want to chaneg property values inside, you can. But you can reassign that whole object again.const
will never be reassigned, but it can change. (e.g. Arrays and Objects)const
if you do not really need to change the variable. You should minimize mutable statevar
is the scope. let
aims to resolve that with local scope.var
is not recommended because of it’s scoping issues.