What is Event Loop, Task Queue, and Microtask Queue in Javascript?

Vamsi Krishna Kodimela
Frontend Simplified
2 min readMay 8, 2024

--

Javascript is, by nature, single-threaded. How does it handle promises and asynchronous methods? How does it even execute them in parallel? The answer may not be straightforward. Let’s explore Javascript Asynchronous Programming…

Well-crafted and well-executed Architecture

Javascript has a well-crafted and well-executed architecture that combines the event loop, task queue, and microtask queue to make single-threaded language perform asynchronous operations.

Let’s take an example…

// Method-1
console.log("A");

// Method-2
setTimeout(()=>{
console.log("B");
},100);

// Method-3
setTimeout(()=>{
console.log("C");
},0);

// Method-4
console.log("D");

/***
*
* Output:
* ADCB
*
***/
  • Whenever execution starts, each method call will enter the CallStack for execution.
  • Methods that can give immediate results (Synchronous…

--

--