January 2018
Beginner
658 pages
13h 10m
English
When we call the setTimeout (2 sec) function, we're actually registering the event callback pair in the Node APIs. The event is simply to wait two seconds, and the callback is the function we provided, the first argument. When we call setTimeout, it gets registered right in the Node APIs as shown here:

Now this statement will finish up, the Call Stack will move on, and the setTimeout will start counting down. Just because the setTimeout is counting down, it doesn't mean the Call Stack can't continue to do its job. The Call Stack can only run one thing at a time, but we can have events waiting to get processed ...