Although as Ellen says, using let could prevent re-declaration of variables, using it can cause issues in older browsers like Internet Explorer. Personally I will use var instead and I will be pretty careful about the variable names.
The variable name I set is as less generic as possible to reduce the possibility to be re-declared.
Although as Ellen says, using
let
could prevent re-declaration of variables, using it can cause issues in older browsers like Internet Explorer. Personally I will usevar
instead and I will be pretty careful about the variable names.The variable name I set is as less generic as possible to reduce the possibility to be re-declared.
You use var inside blocks (like
if-else
and loops) also? There I uselet
because it will prevent accidental value changes in the variable.