1.

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 variableI had been asked this question in my homework.My query is from JavaScript Extensions topic in portion Classes and Modules in JavaScript of JavaScript

Answer»

Right choice is (b) let is CONFINED to a particular function but var is not

Best 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).



Discussion

No Comment Found

Related InterviewSolutions