What is Event Driven Programming in Node.js?

Event-driven Programming is the programming paradigm. In event-driven programming, the flow of execution is determined by the events. Events are handled by event handlers or callbacks. The event loop allows Node.js to perform non-blocking i/o operations despite the fact that JavaScript is single Threaded. It is done by assigning operations to the operating system whenever and wherever possible.

Event Loop is an endless loop, which waits for tasks, executes them, and then sleeps until it receives more tasks. The event loop executes tasks from the event queue only when the call stack is empty i.e. there is no ongoing task. The event loop allows us to use callbacks and promises. The event loop executes the tasks starting from the oldest first.