0
Can you define var, let and const in simple?
Differentiating between var, let and const.
3 odpowiedzi
+ 1
With the advent of ES6, two ways of declaring variables were added: "let and const".
Variables of "let" and "const" are local, (block), variables.
"let" and "const" allow you to declare variables that are scoped to the block, statement, or expression in which they are used.
Variables of "var" defines variables globally, or locally for the entire function, regardless of block scope.
Recommended to use "let" where there is no need to use "var".
Recommended to use "const" where there is no need to use "let" and "var".
❗Tip:
In all the examples given in the lessons, change var to const, if an error occurs, change to "let".
This will help you better understand when to use which type of variable.