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.
Runtime state
Read the phase rail first, then inspect the boxes below for what changed.
Normal code runs first.
Timers wait outside JS.
Promise state changes.
Promise callbacks run next.
Timers run after microtasks.
Logs appear in order.
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
Agentic Loop Simulator
Watch a coding agent run an agentic loop, one step at a time. A planner, a builder, and a judge cycle through plan, build, verify, and repeat until the goal is met. Toggle the separate judge off to see why an agent grading its own work ships confident bugs. An animation-first, interactive explainer of loop engineering and how it maps to Claude Code.
// simulator
SQL Terminal Simulator
Practice SQL in an interactive browser terminal. Learn SELECT, WHERE, ORDER BY, DISTINCT, aggregates, GROUP BY, HAVING, JOINs, subqueries, and window functions against a small e-commerce schema, with single-table queries evaluated live and verified Postgres output.
// simulator
PostgreSQL Terminal Simulator
Practice the psql tool and Postgres engine in an interactive browser terminal. Explore with meta-commands, read real EXPLAIN plans, add an index to turn a sequential scan into a bitmap index scan, and use BEGIN and ROLLBACK to make changes safe, all against a small e-commerce database with verified PostgreSQL output.