Skip to main content

What is the difference between microtasks and macrotasks?

Senior JavaScript
Quick Answer Microtasks (Promise .then, queueMicrotask): processed immediately after current synchronous code, before any macrotask. Macrotasks (setTimeout, setInterval, I/O events): processed one per event loop tick. All microtasks drain completely before the next macrotask runs. This means a long chain of Promise resolutions can delay a setTimeout(fn, 0) callback.

Answer

Microtasks: Executed immediately after current execution stack (Promises, queueMicrotask).

Macrotasks: Executed in next event loop turn (setTimeout, setInterval, I/O).

Crucial for understanding async flow and ordering.

S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice