DEV Community

loading...

Discussion on: 10 JavaScript Interview Questions

Collapse
318097 profile image
Mehul Lakhanpal Author

In the second example,
The callback functions are asynchronous. Therefore, when the for loop has finished, the variable i has a value 5. And when the callback function starts to execute, at that moment it prints the value which is 5.