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
letcould prevent re-declaration of variables, using it can cause issues in older browsers like Internet Explorer. Personally I will usevarinstead 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-elseand loops) also? There I useletbecause it will prevent accidental value changes in the variable.