i

Event Loop

JavaScript is single-threaded, but Node.js is able to perform non-blocking I/O operations. It is possible due to Event Loop and callbacks.

Every API provided by Node.js has an asynchronous alternative. Node thread keeps an event loop, and whenever a task gets completed, it fires the corresponding event, which signals the event-listener function to execute.

All Javascript, v8, and Event loop run In one thread called main thread. This thread listens for events and then triggers callback function when one such event is detected.