The main difference between the variables declared with var and with let is __________

KellyPoima

New member
The main difference between the variables declared with var and with let is __________
A. var is confined to a particular function but let is not
B. let is confined to a particular function but var is not
C. var defines values based on conditions but let does not
D. let doesn’t let you change the value of the variable
 
Answer: b
Explanation: Variables declared with var have global scope whereas variable declared with let have block scope. Variables declared with let are defined only within the closest enclosing block (and any blocks nested within it, of course).
 

Tìm kiếm

Back
Top