Why doesn’t setTimeout(.., 0) execute immediately?
Javascript code runs only on one thread. setTimeout schedules a function to run later. So in js when all currently running code finish its execution , event loop will look for any other event. So setTimeout( .. 0) will make code run after the current loop. console.log(“I’m message from outside timeout”); will be first scheduled … Read more