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() 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.
Array.from(
object, mapFunction, thisValue)
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 |
Type | Description |
An array | The values from the iterable object. |
Array.from()
is an ECMAScript6 (ES6) feature.
ES6 (JavaScript 2015) is supported in all modern browsers:
Chrome | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes |
Array.from()
is not supported in Internet Explorer 11 (or earlier).
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!