+ 2
WHAT IS THE DIFFERENCE OF VAR,LET, CONST
Js(JavaScript)
6 RĂ©ponses
+ 7
Game Europe ,
this is a question that you can check *yourself* by using a siple web search.
> you will get several helpful answers with descriptions and code samples.
+ 7
You can get useful Answers of your question via single web search as Lothar mentioned. but still here is the difference
Var(Variable): Variable is like a container it which we store values
Const: it a keyword use to make a variable value const mean you can't change it anymore if try to it will occur an error
+ 4
It's quite different, let me explain:
var = function-scoped, can be redeclared and updated, hoisted, but undefined before use
let = lock-scoped, can't be redeclared in the same scope, but can be updated
const = block-scoped, can't be redeclared or updated, immutable reference, but object properties can still change
Also just my suggestion, use let and const in modern JavaScript , avoid var
+ 3
let = modern way of declaring variables
const = modern way of declaring variables whose value cannot be changed
You don't have to know the meaning of var. I have never used it before
+ 1
All three can be used to declare variables of any type. However, var and let allow for reassignment of values, whereas const doesnât because const is immutable. Also, var allows for âhoistingâ which means itâs not limited in scope, whereas let and const donât allow hoisting.
Happy coding.