Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
JavaScript - Interview Questions and Answers for 'Let vs var in javascript' - 1 question(s) found - Order By Newest | ||||
| ||||
Ans. Var scopes the variable to the nearest function whereas Let scopes the variable to nearest block. For example - function printNumbers() { for(var i = 1; i < 3: i++){ console.log(i); } console.log(i); // works fine and will print 3 as i has a function scope and not local loop scope } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  let vs var in javascript  let vs var   difference between let and var | ||||
Related Questions | ||||