Course contentsShow
← JavaScript
Lesson 2027 of 2,72342. Iteration Protocols Deep DiveFree lesson

Built-in Async Iterables

Discover which JavaScript built-ins support Symbol.asyncIterator, such as ReadableStreams in Node.js and the browser.

Built-in Async Iterables

You'll learn which JavaScript built-in objects natively support Symbol.asyncIterator and can be consumed with async iteration.

Where Async Iteration Lives Natively

While you can create custom async iterables (as you've learned), JavaScript provides several built-in objects that already implement Symbol.asyncIterator. You don't need to build anything—they're ready to use with for await...of right out of the box.

ReadableStreams: The Primary Built-in

The most important built-in async iterable is ReadableStream, available in both Node.js and modern browsers. Streams represent data arriving over time—perfect for async iteration.

In Node.js:

  • fs.createReadStream() (when using web streams API)
  • HTTP response bodies via fetch()
  • Web Streams API ReadableStreams

In Browsers:

  • fetch() response bodies (response.body)
  • File streams via the File System Access API
  • Transform streams

Think of a ReadableStream like a conveyor belt delivering packages: you don't get everything at once, so async iteration lets you process each item as it arrives.

Other Built-in Async Iterables

Depending on your environment:

  • Node.js Readable streams (traditional stream.Readable with async iterator support added in newer versions)
  • WebSocket data streams in some implementations
  • Async generators returned by built-in functions (though these are technically user-created)

How to Know

Check if an object has async iteration support:

const stream = await fetch(url).then(r => r.body);
console.log(Symbol.asyncIterator in stream); // true

Key Takeaway: JavaScript's built-in async iterables are primarily ReadableStreams (both Node.js and browser), making streaming data sources naturally consumable with for await...of without custom implementation.