Write your answers below.
Knowing the output is not that important, understanding why the output is important!
Thanks for reading π
Follow @codedrops.tech for daily posts.
Instagram β Facebook
Micro Learning β Web Development β Javascript β MERN stack
codedrops.tech

Top comments (3)
For each tick of your loop (5 ticks in total), it'll schedule
console.logto be run with the value ofiafter1000ms.Meaning that in approximately ~1200ms (1000ms of the schedule plus some ms of the execution operation) after the execution of this code, the console will display
0,1,2,3,4.Am I correct?
Good explanation but its wrong.
varis scoped functionally and also because of closures, the value ofiwould be5when thecbis executed. Hence, it will print outHa! You got me! Thanks for clarifying!