Running the async code

The next thing that happens in our program is we run our console.log statement, which prints Finishing up to the screen. This is the second message that shows up in the Terminal:

This statement runs, our main function is complete, and it gets removed from the Call Stack.

At this point, the Event Loop says hey I see that we have nothing in the call stack and we do have something in the Callback Queue, so let's run that callback function. It will take the callback and move it into the Call Stack; this means the function is executing:

It will run the first line which is sitting on line 8, console.log, printing Second setTimeout ...

Get Learning Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.