Typed Array from()
Description
The from()
method returns a typed array from any object with a length property.
The from()
method returns a typed array from any iterable object.
Note
from()
is a static property of Typed Array objects.
You can only use it as typed-array.from().
Using x.from(), where x is not a typed array will return undefined.
Syntax
typed-array.from(object, mapFunction, thisValue)
typed-array must be one of the following: Int8ArrayUint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float16Array Float32Array Float64Array BigInt64Array BigUint64Array |
Parameters
Parameter | Description |
iterable | 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 |
Typed array | A typed array with the values from the iterable object. |
JavaScript Typed Arrays
Browser Support
typed-array.from()
is an ECMAScript6 (ES6 2015) feature.
JavaScript 2015 is fully 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 |
typed-array.from()
is not supported in Internet Explorer.