So my mentor challenged me to study about the Event Loop before our next meeting and I realised while we learn about the Event Loop as a theoretical concept, very few understand how it works in practice.
We’re all taught that Javascript is single threaded, meanwhile it can handle asynchronous operations like API calls, timers, and file reading without blocking execution. At first, this feels contradictory. How can a language that runs only one operation at a time manage multiple tasks efficiently? This is the core idea behind the event loop.
To understand how the event loop works, we first need to look at where JavaScript actually executes code: the call stack.
The call stack is where JavaScript keeps track of function execution. It determines which function is currently running and what should run next. You can think of it as a stack of books.
Whenever a function is called, it is added (or “pushed”) onto the stack. When that function finishes execution, it is removed (or “popped”) from the stack. Because of






