+ 2

WHAT IS THE DIFFERENCE OF VAR,LET, CONST

Js(JavaScript)

15th Dec 2024, 11:53 AM
Game Europe
Game Europe - avatar
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.
15th Dec 2024, 11:59 AM
Lothar
Lothar - avatar
+ 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
15th Dec 2024, 2:24 PM
Alhaaz
Alhaaz - avatar
+ 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
17th Dec 2024, 11:30 AM
☕AstroParrot✩
☕AstroParrot✩ - avatar
+ 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
15th Dec 2024, 2:01 PM
RuntimeTerror
RuntimeTerror - avatar
+ 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.
17th Dec 2024, 8:38 AM
Joseph Focha
Joseph Focha - avatar