Asynchronous JavaScript
One thread, thousands of things waiting. Build the model that makes async JavaScript predictable: the event loop and its two queues, callbacks and why they lost, promises, async/await, the concurrency patterns real apps need, cancellation, async iteration, and the bug list every reviewer checks first.
What you will be able to do
- Explain what blocking costs and why one thread is not a limitation you can code around
- Predict the exact output order of a script mixing sync code, microtasks and timers
- Read and write error-first callbacks, and name the two problems that killed them
- Build promises by hand, chain them correctly, and promisify a callback API
- Use async/await without accidentally serialising independent work
- Reach for all, allSettled, race or any deliberately, and know which failure mode each has
- Write a limited-concurrency pool, a retry with backoff and a timeout wrapper from scratch
- Cancel in-flight work with AbortController, including cooperative cancellation in loops
- Consume a paginated API with an async generator and for await...of
- Spot missing awaits, floating promises, async forEach and stale-state races in review
Lessons
- Sync vs Async — Synchronous code owns the thread until it returns. Asynchronous code hands the waiting to somebody else and asks to be called back. (12 min)
- The Event Loop — Run one task to completion, then drain every microtask, then maybe paint. Repeat forever. (18 min)