Skip to Content
0 likes
Closures for Private State: A Counter You Can't Break Level: Advanced

Keep a counter's value in a closure so nothing outside can set it to -5 or "abc". The pattern, how it compares with a class with

0 likes
Fix a Bound Event Listener That Will Not Detach Level: Advanced

Trace a wrong callback receiver, bind one stable listener, and verify start, stop and restart without duplicate or stale subscriptions.

0 likes
Predict the Output: Event Loop Order in 6 Snippets Level: Advanced

Six short snippets with setTimeout, promises, await and queueMicrotask. Predict the order, run it, then read why. The one rule: sync code first, then all microtasks, then the next task.

0 likes
Batch API Calls With Promise.allSettled Level: Advanced

Send many requests, keep the successes, and report the failures instead of losing everything to one rejected promise. Plus limiting how many run at once.

0 likes
Paginate an API With an Async Generator Level: Advanced

Hide page numbers and "next" links inside an async generator, then loop over every record with for await. Stop early and the remaining pages are never fetched.