Roadmaps / JavaScript / Phase 1
Phase 1 of 4 · Study weeks 1-4
The language, the event loop and bounded concurrency
This phase makes the first checkpoint possible: a fetch core that never runs away, stops when told and shows when it blocks.
Topics every week
- Week 18 h
- Values, coercion and equality
- Scope, closures and hoisting
thisand prototypes- Property order and the spec's own algorithms
Hand inA catalogue of 20 traps, each with a
node:testcase and the rule that explains it - Week 28 h
- Iterators, generators and symbols
- Promises and the microtask queue
asyncandawaiterror handling- Promise combinators and what they do with losers
Hand inA small async toolkit (retry, timeout, map with limit) with tests for each failure
- Week 38 h
- The Node event loop phases and the browser's task and render cycle
process.nextTick, microtasks and starvationmonitorEventLoopDelay- Blocking work and chunking
Hand inA starvation lab and a delay report with your prediction beside the result
- Week 48 h
- Concurrency limits and per-key queues
AbortSignal,AbortSignal.timeoutandAbortSignal.any- Backpressure and load shedding
- Little's law for sizing
Hand inCheckpoint 1: the fetch core, its tests and the worked-reference table
Practice projects
- Practice 1, the trap catalogue (Weeks 1 and 2): write 20 expressions that surprise experienced engineers and explain each one. Done when: every entry has a test that asserts the surprising result and a one-line rule, and at least five cite a section of the ECMAScript specification.
- Practice 2, microtask starvation (Week 3): write code that delays timers by 200 ms or more with a microtask loop, then fix it. Done when: a delay histogram shows the stall before and p99 of 20 ms or less after, and you can say why a
setImmediateyield fixes it and a second promise does not. - Practice 3, a bounded queue (Week 4): build a queue with a limit, per-key fairness and cancellation. Done when: 5,000 tasks queued at once never run more than the limit, memory stays flat, and a cancelled task never starts.
- Optional, a generator-based scheduler: run cooperative tasks with generators. Done when: two tasks interleave deterministically and a test proves the order.
GitHub repos to study
Existence, last commit and README notices were checked on 22 Nov 2026 by shallow clone. Every repository below had a commit in the last six months. Archive status comes from the README, not from the GitHub setting, so look again before you rely on one.
| Repo | What to read | Week |
|---|---|---|
| tc39/ecma262 | The algorithm for each trap in your catalogue | 1 |
| getify/You-Dont-Know-JS | The 2nd edition chapters on scope, closures and this | 1 |
| tc39/test262 | How the language is tested: read the tests for one feature | 2 |
| nodejs/node | The lib/ timer and task-queue code, to see where microtasks drain | 3 |
| libuv/libuv | The event loop documentation and uv_run | 3 |
Milestone checkpoint
Build the fetch core (Checkpoint 1 above). Write the test harness first: a local fake server with hung, slow and fast hosts, and a counter that records the highest number of requests in flight. Then add the limits, the timeout and abort propagation. Finish by adding the delay monitor to the test run and the seeded 200 ms loop that must fail it. Hand in the worked-reference table with your own numbers and ADR-1 and ADR-2.
Check yourself
Answer each question in your head first, then open it to check.
In a CommonJS main module, in what order do
setTimeout(f, 0),setImmediate(g),Promise.resolve().then(h)andprocess.nextTick(k)run?k, thenh, thenfandgin an order Node does not guarantee from the main module. (In an ES modulehcan run beforek, because module evaluation itself runs inside a promise job.)Why is a
forloop withawaitover 100 URLs slow, and why isPromise.allover 100,000 URLs dangerous?Serial awaits add every latency together. Unbounded fan-out opens too many sockets and holds every result in memory. Use a pool with a limit.What does
AbortSignal.timeout(5000)stop, and what does it leave running?It aborts operations that accept the signal, such asfetchand streams. Work that ignores the signal, including synchronous code, keeps running.Why report event-loop delay at p99 and not the mean?
Delay measures how long synchronous work blocks the loop. The mean hides the rare long stall that users feel as a slow response.Why can a microtask loop freeze timers while a loop of
setImmediatecalls does not?The microtask queue drains completely before the loop moves on, so microtasks that keep scheduling microtasks never let it advance. AsetImmediatecallback that schedules another runs on the next loop turn, so timers and I/O still get a turn.