JavaScript Promises & Async/Await Simulator
Visualize JavaScript promises, async/await, microtasks, task queues, setTimeout ordering, rejection handling, and Promise.all with an interactive event-loop simulator inspired by classic JavaScript visual guides.
Category: Programming
Topics covered: javascript, promises, async-await, event-loop, microtasks, settimeout, nodejs, programming, frontend, backend, educational, interactive
// simulator
JavaScript Promises & Async/Await Simulator
Visualize JavaScript promises, async/await, microtasks, task queues, setTimeout ordering, rejection handling, and Promise.all with an interactive event-loop simulator inspired by classic JavaScript visual guides.
// event loop lab
Start in global execution
The script begins on the call stack. Nothing async has been scheduled yet.
Event loop trace
Follow the current callback from execution to queues and back to output.
What gets printed first after Start?
About this JavaScript async simulator
What you'll learn
- Why synchronous code runs before promise callbacks and timers
- How fulfilled, rejected, and pending promise states affect handler execution
- Why promise callbacks are microtasks, while timers are tasks
- How async functions run until await and then resume later
- How catch and finally behave after a promise rejection
- How Promise.all waits for several async operations at once
Visual model covered
- Call stack: currently executing synchronous JavaScript
- Runtime APIs: timers, network work, and other browser or runtime-owned async work
- Microtask queue: promise handlers, queueMicrotask callbacks, and async function continuations
- Task queue: timer and event callbacks that run after microtasks drain
Inspired by a classic visual guide
This simulator is an original interactive companion inspired by Lydia Hallie's popular JavaScript visualized article on promises and async/await. It uses its own diagrams and step logic while covering the same core mental models.
Browser-safe by design
The simulator does not execute arbitrary JavaScript. Each scenario is modeled as a deterministic event-loop trace so learners can step backward, make predictions, and see exactly why the output order changes.
Try next
// simulator
Fork Bomb Simulator
Visualize how the infamous :(){ :|:& };: fork bomb works. Watch processes multiply exponentially, exhaust system resources, and learn how to protect against it with ulimit, cgroups, and systemd.
// simulator
AWS VPC Networking Simulator
Learn AWS networking fundamentals with an interactive VPC simulator. Visualize how traffic flows through public and private subnets, understand NAT Gateways, Internet Gateways, and route tables.
// simulator
DNS Resolution Simulator
Learn how DNS works with an interactive step-by-step simulator. Visualize the DNS hierarchy, understand caching at different levels, and see the difference between recursive and iterative queries.