What is the event loop in Node.js, and how does it work?

The event loop is a core part of Node.js that enables non-blocking I/O operations by allowing JavaScript code to run asynchronously. It manages the execution of code, collects and processes events, and executes queued sub-tasks. The event loop operates in phases, including timers, I/O callbacks, idle, and poll phases. It starts with the execution of the global code, then moves through each phase, executing callbacks and resolving promises as needed.