+ 1
What is the defrence between Var , const ,let in JavaScript ?
Var,const,let
5 Respostas
+ 2
These have really good explanation
https://code.sololearn.com/WdGAFeNRAe9M/?ref=app
https://code.sololearn.com/WX4dAZq1IMBv/?ref=app
+ 10
# var, let & const
• https://academind.com/learn/javascript/var-let-const/
While 'const' and 'let' variables are scoped by code blocks, functions or modules,
'var' variables are scoped only by functions or modules.
Check out this article about javascript scope variable — https://dmitripavlutin.com/javascript-scope/
Yacine Becha Please,
Try to use the search bar future as you can find many similar threads and to avoid from posting duplicate!
+ 6
I'll say in three sentences :
var : To make a global variable
let : allows you to make local variable
const : used to make a constant (not a variable, which means you can't change once you declare it)
Example :
var name = 'something';
You can now access the name variable anywhere from the script.
const sayName = () => {
let name = 'something';
}
This name variable is just accesible inside the sayName function.
const name = 'something';
name = 'lol'; // name will not ever change, bcz it is supposed to be a constant.
Hope this helps :))
0
Thanks for helping