JavaScript - Interview Questions and Answers for 'Let vs var in javascript' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

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.
Label / Company      Label / Company / Text

   



JavaScript - Interview Questions and Answers for 'Let vs var in javascript' - 1 question(s) found - Order By Newest

 Q1. Difference between Let and Var in Javascript ?JavaScript2020-01-23 13:23:25

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




Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: