In other course variables vere noted with let, in which cases i should use let and in which var ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

In other course variables vere noted with let, in which cases i should use let and in which var ?

23rd Aug 2019, 8:48 PM
nothing there
nothing there - avatar
2 Answers
+ 2
Let is only usable in its declared position. Lets say you started a function and in there, there is an if condition. You declared a let in there. You cant use that in other parts in the function. But if you use var in there, you can use it everywhere. You can use it to avoid confusion.
23rd Aug 2019, 9:20 PM
Tugay Mandal
+ 1
Usually in ECMAScript 6, you should use let for less confusion. (Also, if you know something will be constant, you should always use const)
23rd Aug 2019, 9:13 PM
Airree
Airree - avatar