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.
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.
+ 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
+ 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
0
Thanks for your time and your answer
0
Thank you guys, i have a full understanding now you clear it for me, the duck thanks you 🤩