Event Driven Programming
Event-driven programming is a programming paradigm where the flow of a program is determined by external "events" like user actions (mouse clicks, key presses), system notifications, or sensor inputs, meaning the program reacts and executes code only when a specific event occurs, rather than following a linear sequence of instructions.
Has higher priority than the Macro-task queue
Promises
and Async
functionsPromise async function
Runs when microtask queue is empty
Browser APIs UI rendering `.then()` Callback functions after async/Promise
setTimeout() setInterval() setImmediate()
Event loop is something that constantly runs to handle functions across the tasks.
Check the Macrotask queue
After that original macrotask completes, all available microtasks are processed
In next cycle, function is passed to the Call stack