+ 1
Javascript: let, const and var?
Should I create variables with let and const instead of var keyword? I know what's the difference between them but I just don't understand why those two keywords exist... For example, if the value of a variable shouldn't change, we could use const, but we also can simply use var and don't change the value of the variable into the code and then everything's fine...
1 Respuesta
+ 8
If the value of a variable is never meant to be changed in your code const is more appropriate to use as it cannot be changed accidentally and it also conveys your intent to anyone else reading the code.