0

Hello, this question is about Javascript

Please, i am really confused, what is the difference beetwen 'let', 'var' and 'const', i think that const stands for making a variable and don't be able to change after.

17th Aug 2021, 9:51 PM
DUCK 🥰
DUCK 🥰 - avatar
5 odpowiedzi
+ 4
variables declared with var keyword are global and can be used anywhere in your program. let variables are local, i.e their values can only be used inside a particular block of code and not anywhere else. const variables holds values that remains the same. E.g PI(3.14...) they are read only.
18th Aug 2021, 7:44 PM
Emms
Emms - avatar
+ 3
var - can be redeclare - has local scope in function and global in program let - can't be redeclare - has block scope const - ones value is initialized can't be changed
19th Aug 2021, 3:29 PM
Mohd Saqib
Mohd Saqib - avatar
+ 2
let creates a local variable, var creates a global variable, const creates a variable that cannot be reassigned. You should use const when you can, if you need to reassign then use let. In modern JavaScript, unless absolutely needed, you should never use the var keyword as it's just outdated
17th Aug 2021, 10:07 PM
inxanedev!
inxanedev! - avatar
0
Thanks for your time and your answer
18th Aug 2021, 12:37 AM
DUCK 🥰
DUCK 🥰 - avatar
0
Thank you guys, i have a full understanding now you clear it for me, the duck thanks you 🤩
20th Aug 2021, 1:11 AM
DUCK 🥰
DUCK 🥰 - avatar