Node.js made JavaScript so valuable by adding most important features that are not available in JavaScript. Without node we can’t run JavaScript in our local pc. We have to install node.js first before we are starting to work with JavaScript but we can run JavaScript in some platforms without node.Node.js is a platform based on events. That means anything that happens in Node is the reaction to an event. A Node-passing transaction navigates a sequence of callbacks. Completely separated from the developer, all of these are handled by a library called libuv that offers an event loop method.
The event loop is the platform’s most confusing concept. So most of the developers are understanding Event Loop in wrong Term. So we need to clarify those misconception first.
1.Event loop Thread
There can only be one thread running JavaScript code which is the thread running the event loop. Callbacks processing (acknowledging that every user code is a callback running in a Node.js application) is performed via the event loop.
2.Every Asynchronous calls are handled by a thread pool
By example, Libuv generates a thread pool of four threads to discharged asynchronous work. Operating systems of today already provide asynchronous interfaces for many I / O functions (such as AIO on Linux). Libuv will use those asynchronous interfaces wherever possible, avoiding thread pool use. The same holds true for third party subsystems such as databases. ⠀
3.Event Loop is Similar to stack or queue
Although there are queue-like structures included, event loop doesn’t run via the stack process. As a process, the event loop is a series of phases with specific tasks that are executed in round-robin.
Phases of Event Loop Cycle

Event Loop cycle consist of main phases in it’s process. To understand event loop better we need to be familiar with these phases.
Timer
Timer callbacks of JavaScript(setTimeout, setInterval) are maintained in the heap memory till the callbacks expire. If the heap holds any expired timers, the event loop takes the related callbacks and begins operating those in the ascending order of their delay till the queue of timers is empty. The executing of the timer callbacks is regulated by the the Poll phase.
Pending callbacks:
The event loop in this process performs any system-related callbacks available. For example, let’s say you’re creating a node server and some other process uses the port on which you want to run the method, node may throw an ECONNREFUSED error, some of* nix systems might want the callback to hold for execution because of some other tasks still operating in the system are performing.
Idle/Prepare:
Event Loop remain idle in this phase.
Poll
It’s this step that makes Node.js special. The event loop is watching out for new async I / O callbacks during this process. All callbacks are executed, except the callbacks setTimeout, setInterval, setImmediate, and closing. In this step, the event loop basically does two things:
1.When callbacks are already queued in the poll phase queue, then they will be executed until all callbacks are taken from the callback queue of the poll process.
2. If the queue contains no callbacks, the event loop remains in the poll process for some time. It may vary on some scenarios
Check/setImmediate
In this step, the event loop takes the callbacks from the queue of the Check process and begins one by one executing until the queue is empty. The event loop should come to this process when there are no more callbacks to be executed during the poll phase and the poll phase is idle. In this step the setImmediate callbacks are usually executed.
Closing callbacks
The event loop, in this step executes the callbacks associated with the closing events such as socket.on(‘close’, fn) or process.exit)
Microtasks
The microtasks include tasks such as setTimeout, setInterval, setImmediate, requestAnimationFrame, I / O, UI rendering, or other I / O callbacks. They have no such thing as event loop prioritization. The callbacks are performed according to phases of the event loop.

Above figure explains how event loop really works. It iterate again and again until there are no callbacks or other task to perform. Technically a Tick is known as the one iterate of event loop and tick duration is the time taken to complete it.
So we have clearly gone through the event loop phases. If we have a clear knowledge on how event loop works then I think you are ready for node.js