Favorites

JavaScript for await...of Statement

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
for await...of
JavaScript IterationThis statement is supported by all modern browsers.
Updated 28th November 2026

The for await...of statement loops over values that arrive asynchronously, such as from an async generator or a list of promises, waiting for each one.

Description

The for await...of statement creates a loop over async iterables, such as async generators and readable streams, as well as ordinary iterables of promises. Each iteration waits for the next value before running the body, so items are processed one at a time, in order.

It can only be used where await is allowed: inside an async function or at the top level of a module. To process promises in parallel rather than one by one, use Promise.all().

The loop works with any object that implements Symbol.asyncIterator, which includes async generators and, in modern browsers, ReadableStream, so you can process a fetch() response body chunk by chunk. If you break out of the loop or an error is thrown inside it, the iterator's return() method is called so it can clean up, for example by closing a stream.

Syntax

for await (const item of asyncIterable) {
  statements
}

Example

async function* ticker(n) {
  for (let i = 1; i <= n; i++) {
    await new Promise(r => setTimeout(r, 150));
    yield i;
  }
}

(async () => {
  for await (const t of ticker(3)) console.log('tick', t);
  console.log('done');
})();

Browser Support

The following information will show you the current browser support for the for await...of statement. Hover over a browser icon to see the version that first introduced support for this statement.

This statement is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee