Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
The Array.from() static method creates a new, shallow-copied Array instance from an iterable or array-like object.
An iterable or array-like object to convert to an array.
mapFn OptionalA function to call on every element of the array. If provided, every value to be added to the array is first passed through this function, and mapFn's return value is added to the array instead. The function is called with the following arguments:
elementThe current element being processed in the array.
indexThe index of the current element being processed in the array.
thisArg OptionalValue to use as this when executing mapFn.
A new Array instance.
Array.from() lets you create Arrays from:
To convert an ordinary object that's not iterable or array-like to an array (by enumerating its property keys, values, or both), use Object.keys(), Object.values(), or Object.entries(). To convert an async iterable to an array, use Array.fromAsync().
Array.from() never creates a sparse array. If the items object is missing some index properties, they become undefined in the new array.
Array.from() has an optional parameter mapFn, which allows you to execute a function on each element of the array being created, similar to map(). More clearly, Array.from(obj, mapFn, thisArg) has the same result as Array.from(obj).map(mapFn, thisArg), except that it does not create an intermediate array, and mapFn only receives two arguments (element, index) without the whole array, because the array is still under construction.
Note: This behavior is more important for typed arrays, since the intermediate array would necessarily have values truncated to fit into the appropriate type. Array.from() is implemented to have the same signature as TypedArray.from().
The Array.from() method is a generic factory method. For example, if a subclass of Array inherits the from() method, the inherited from() method will return new instances of the subclass instead of Array instances. In fact, the this value can be any constructor function that accepts a single argument representing the length of the new array. When an iterable is passed as items, the constructor is called with no arguments; when an array-like object is passed, the constructor is called with the normalized length of the array-like object. The final length will be set again when iteration finishes. If the this value is not a constructor function, the plain Array constructor is used instead.
The from() method can be called on any constructor function that accepts a single argument representing the length of the new array.
When the this value is not a constructor, a plain Array object is returned.
| ECMAScript® 2027 Language Specification # sec-array.from |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Jul 10, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.