Frontend: Explain the JavaScript Event Loop
Contrast how microtasks, macrotasks, and rendering queues are ordered and processed by the engine.
Technical Reference & Key Concepts
The Challenge: Explain the Event Loop
An interviewer asks you to trace the execution order of synchronous code, promises, setTimeout, and requestAnimationFrame.
Core questions to address:
- What is the difference in execution priority between a Promise callback (microtask) and a setTimeout callback (macrotask)?
- In what phase of the loop is the DOM rendering queue executed?
- What happens if a microtask recursively schedules another microtask?