JavaScript Array.from()
Description
The Array.from()
method returns an array from any object with a length property.
The Array.from()
method returns an array from any iterable object.
Array.from()
Array.from() is a static property of the JavaScript Array object.
You can only use it as Array.from().
Using x.from(), where x is an array will return undefined.
Syntax
Array.from(object, mapFunction, thisValue)
Parameters
Parameter | Description |
object | Required. The object to convert to an array. |
mapFunction | Optional. A map function to call on each item. |
thisValue | Optional. A value to use as this for the mapFunction |
Return Value
Type | Description |
An array | The values from the iterable object. |
Array Tutorials:
Browser Support
Array.from()
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers since June 2017:
Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |
Array.from()
is not supported in Internet Explorer.