We expect JS to wait 3 sec, print 1 and then go down and print the string. But JS prints string immediately, waits 3 sec and then prints 1. The function inside setTimeout forms a closure (remembers ...
setTimeout with timer of 5 secs sometimes does not exactly guarantees that the callback function will execute exactly after 5s. The First rule of JavaScript: Do not ...