JavaScript
/
02 Sep 2026
/
4 min read
JavaScript promises represent one future result. Many systems produce a sequence of future results instead: paginated records, stream chunks, queue messages, or events from an asynchronous source.
Async iteration models that shape directly. An async iterable exposes values over time, and for await...of consumes them one at a time.
A minimal async generator An async generator can yield values after asynchronous work:
async function* pages() { for (let page = 1; page <= 3; page++) { const response = await fetch(`https://example.com/api/items?page=${page}`); if (!response.ok) { throw new Error(`HTTP ${response.status}`); } yield await response.json(); } } for await (const page of pages()) { console.log(page); } The consumer does not need to know how pagination is implemented. It only sees an asynchronous sequence.