DEV Community


Discussion on: 10 JavaScript Interview Questions

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.