

Node Processes the provided input script, in this case, app.js, each time that either on our code or any library we import an asynchronous call gets started, Node will allocate such call into the event loop.Īfter the input script is finished being processed ( app.js in this case), then Node start the processing of the event loop and the asynchronous events allocated in it, in the following order of the following phases (described in the image in the right) The event loop gets initialized, this is what handles Node.js asynchronous events which allow performing non-blocking I/O operations - despite the fact that JavaScript is single-threaded - it does so by offloading operations to the system kernel whenever possible, we will go into further detail about the inner workings of the event loop. First Node.js loads into their respective scopes all the functions, including the Node internal functions like require(), and user-defined functions like helloWorld(), because of this you can use functions before they are declared as long as you are within the same scope, give it a try moving the call to helloWorld() from line 9 to line 2.
