DEV Community

Discussion on: The World famous javascript interview question

Collapse
 
ml318097 profile image
Mehul Lakhanpal

Good explanation but its wrong. var is scoped functionally and also because of closures, the value of i would be 5 when the cb is executed. Hence, it will print out

5
5
5
5
5
Collapse
 
chiefgui profile image
Guilherme Oderdenge

Ha! You got me! Thanks for clarifying!