JavaScript Array fromAsync() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

In JavaScript, Array.fromAsync(source) is a static method that builds a new Array from an async iterable (or an iterable of thenables). It awaits each value. An optional mapFn can be async too (ES2024).

Remember
await Array.fromAsync(source)
await Array.fromAsync(source, mapFn)

await Array.fromAsync([Promise.resolve(1), Promise.resolve(2)])
  → [1, 2]
await Array.fromAsync([1, 2, 3], async (n) => n * 2)
  → [2, 4, 6]

static — call Array.fromAsync(...), not arr.fromAsync(...)
vs Array.from — sync only

Syntax

Call Array.fromAsync. Start with this line.

JavaScript
Array.fromAsync(source, mapFn?, thisArg?)
CallWhat it does
Array.fromAsync(source, mapFn?, thisArg?)Primary signature.
await Array.fromAsync(...)Await the Promise to get the new array.

Built into modern JavaScript (ES2024). Call Array.fromAsync(...) on the Array constructor — no import required.

Library declarations
JavaScript
Array.fromAsync(source, mapFn?, thisArg?)

Parameters

ParameterDescription
sourceRequired. Async iterable, or iterable of thenables / values
mapFnOptional. Transform each item (may be async)
thisArgOptional. this for mapFn

Return Value

Return ValueDescription
Promise<Array>Promise that resolves to a new Array

JavaScript Examples

Example 1 — Array of Promises

Pass an array of Promises — each value is awaited into the result.

JavaScript
const nums = await Array.fromAsync([
  Promise.resolve(1),
  Promise.resolve(2),
  Promise.resolve(3)
]);

console.log(nums);
// [1, 2, 3]
Try It Yourself

How It Works

  1. Source is thenables. Each element is a Promise that resolves to a number.
  2. Await each value. fromAsync waits for every Promise.
  3. Build a real Array. Resolved values become [1, 2, 3].
  4. Await the call. The method itself returns a Promise — use await.

Example 2 — Async mapFn (Double Values)

The second argument can be async — each mapped result is awaited.

JavaScript
const doubled = await Array.fromAsync(
  [1, 2, 3],
  async (n) => n * 2
);

console.log(doubled);
// [2, 4, 6]
Try It Yourself

How It Works

  1. Sync source. [1, 2, 3] is a normal array.
  2. Async mapFn. async (n) => n * 2 returns a Promise per item.
  3. Await mapped results. Each doubled value is awaited before push.
  4. One call. Like mapping with async work, then collecting into an array.

Example 3 — Async Generator

Read values from an async generator (a simple async iterable).

JavaScript
async function* count() {
  yield await Promise.resolve(10);
  yield await Promise.resolve(20);
  yield await Promise.resolve(30);
}

const arr = await Array.fromAsync(count());

console.log(arr);
// [10, 20, 30]
Try It Yourself

How It Works

  1. Async generator. async function* yields values over time.
  2. Fake delay. Each yield awaits Promise.resolve(...) (a tiny async step).
  3. fromAsync consumes. It walks the async iterable until done.
  4. Result array. You get [10, 20, 30] in one Promise.

Browser & Runtime Support

Array.fromAsync() is part of ES2024. It awaits async iterables and optional async map functions—unlike sync Array.from().

✓ ES2024

Array.fromAsync()

Supported in Chrome 123+, Firefox 128+, Safari 18+, Edge 123+, and Node.js 22+. Not available in older browsers without a polyfill.

78% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Array.fromAsync() Growing

Bottom line: Safe for current evergreen browsers and Node 22+. Fallback: for await (const x of source) result.push(x), or use Array.from for sync-only sources. Feature-detect with typeof Array.fromAsync === "function".

Frequently Asked Questions

Array.fromAsync() builds a new Array from an async iterable (or an iterable of thenables). It awaits each value, then resolves to the finished array. An optional mapFn can also be async.
Yes. It always returns a Promise. Use await Array.fromAsync(source) inside an async function, or call .then() on the Promise.
Array.from() is synchronous and does not await Promises. Array.fromAsync() awaits async iterables and awaited mapFn results, so it fits async data sources.
It is a static method on the Array constructor. Call Array.fromAsync(source), not someArray.fromAsync(source).
Yes. If mapFn returns a Promise (or is an async function), Array.fromAsync awaits each mapped result before placing it in the new array.
Array.fromAsync() is ES2024. It works in Chrome 123+, Firefox 128+, Safari 18+, Edge 123+, and Node.js 22+. Older runtimes need a for await…of fallback.

Next: Array.isArray()

Learn how to reliably check whether a value is an array.

isArray() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful