0

Whats the diffrence between let and var in JavaScript

Let x = 10; var x = 10;

25th Jun 2021, 4:07 PM
Predator
Predator - avatar
3 Réponses
25th Jun 2021, 4:33 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Both are variables only but only difference is let block scoped u will have access only to that block like 'for' block and 'while' block , :>var is function scoped u can access anywhere in that function.
25th Jun 2021, 4:36 PM
Nivya
Nivya - avatar
0
var and let are both used for variable declaration in javascript but the difference between them is that var is function scoped and let is block scoped. It can be said that a variable declared with var is defined throughout the program as compared to let.
27th Jun 2021, 10:49 AM
Prachi Rajgor
Prachi Rajgor - avatar