I am a believer of the Root Cause Analysis. Ask "How, What, Why" until you can dissect it with no further to go. Well, I am a frontend developer ready for new challenges!
let is a block scope. so the value of i gets captured. in case of var its a global scope/scope of where the function is called. so when the function actually executes, the var i value is the last standing value, which is not the case with let.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
in the interview question about closure
why does it shows a different result when you use let in the for loops ?
let is a block scope. so the value of i gets captured. in case of var its a global scope/scope of where the function is called. so when the function actually executes, the var i value is the last standing value, which is not the case with let.