intermediate
Async JavaScript tasks
Reason about promise coordination, concurrency limits, cancellation, retries, and output order.
Async JavaScript interview tasks combine language semantics with coordination: run promises sequentially, limit concurrency, retry with backoff, cancel stale work, or predict event loop output. The solution must preserve ordering requirements while avoiding unbounded parallel work.
Trade-off: compare time, memory, and implementation complexity before committing to a structure or pattern.
On interviews: Interviewers expect you to know the difference between creating promises, awaiting them, and scheduling callbacks into microtasks or tasks.
Common pitfalls: Array.map with async callbacks starts all work immediately. Promise.all fails fast. Cancellation needs explicit AbortController or cooperative checks; ignoring stale results is not the same as stopping work.
Checklist:
- Separate creation from awaiting.
- Limit concurrency deliberately.
- Handle rejection policy.
- Define cancellation behavior.