Once the Stack is clear, the event loop triggers and checks the Task Queue for available callbacks. No AJAX?….
Once the timer expires, in this case immediately as we put 0 as the timeout, the callback function is put in the Message Queue.
You'll love it. For example, if you set the setTimeout timeout to 2 seconds, you don’t have to wait 2 seconds - the wait happens elsewhere. You mainly need to be concerned that your code will run on a single event loop, and write code with this thing in mind to avoid blocking it. Some other thread seems to have helped us execute that timeout since we are pretty sure a thread can only execute one single task at any point in time. i.e., executing its code with more than one thread? The blocking code keeps running without blocking the main execution thread.