Node.js Course
Node.js
/
Advanced

Event Loop Coding Questions

Definition

Trick questions designed to test your exact knowledge of the Microtask vs Macrotask queues and execution order.

Explain Like I'm New

The interviewer gives you a 15-line block of code containing nested `setTimeout`, `Promise.resolve`, `process.nextTick`, and synchronous `console.log` statements. They ask: 'What is the exact output order in the terminal?'.

Real World Example

These questions are extremely common at Big Tech (FAANG) interviews to filter out candidates who don't deeply understand JavaScript.

Common Use Cases

  • •Advanced technical interviews

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • Does `Promise.resolve().then()` run before or after `setTimeout(..., 0)`?

intermediate

  • What happens if `process.nextTick` calls itself recursively?

Flash Cards

Question

Promise vs setTimeout?

Click to reveal answer
Answer

Promise runs first! Promises go to the Microtask queue, which has higher priority and completely drains before the Event Loop even looks at the Timers (setTimeout) queue.

Question

Recursive nextTick?

Click to reveal answer
Answer

It completely blocks the Event Loop. Because `nextTick` has the absolute highest priority, Node will endlessly process the recursive `nextTick` calls and will NEVER move on to network requests or timers. Your server will freeze.