Callback Queue (Task Queue)
A queue that holds messages (callbacks) to be processed. When the call stack is empty, the event loop picks functions from this queue to execute, enabling asynchronous behavior in JavaScript.
β’ Macro Task Queue: Holds tasks like setTimeout, setInterval, and I/O operations. These tasks are executed in a first-in-first-out (FIFO) order after the current stack is cleared.
β’ Micro Task Queue: Contains tasks such as promise resolutions and process.nextTick() callbacks. Microtasks have higher priority and are executed immediately after the current operation completes and before any macrotasks.