The TypedArray.from() method creates a new typed array from an array-like or iterable object. This method is nearly the same as Array.from().


TypedArray.from(source[, mapFn[, thisArg]])

where TypedArray is one of:



An array-like or iterable object to convert to a typed array.
Optional. Map function to call on every element of the typed array.
Optional. Value to use as this when executing mapFn.

Return value

A new TypedArray instance.


TypedArray.from() lets you create typed arrays from:

  • array-like objects (objects with a length property and indexed elements) or
  • iterable objects (objects where you can get its elements, such as Map and Set).

TypedArray.from() has an optional parameter mapFn, which allows you to execute a map function on each element of the typed array (or subclass object) that is being created. More clearly, TypedArray.from(obj, mapFn, thisArg) is the same as TypedArray.from(Array.prototype.map.call(obj, mapFn, thisArg)).

The length property of the from() method is 1.

Some subtle distinctions between Array.from() and TypedArray.from():

  • If the |this| value passed to TypedArray.from is not a constructor, TypedArray.from will throw a TypeError, where Array.from defaults to creating a new Array.
  • TypedArray.from uses [[Put]] where Array.from uses [[DefineProperty]]. Hence, when working with Proxy objects, it calls handler.set to create new elements rather than handler.defineProperty.
  • When from gets an iterator, the TypedArray version first collects all the values from the iterator, then creates an instance of |this| using the count, then sets the values on the instance. Array.from sets each value as it gets them from the iterator then sets the length at the end.
  • When Array.from gets an array-like which isn't an iterator, it respects holes, where TypedArray.from will ensure the result is dense.


// Set (iterable object)
var s = new Set([1, 2, 3]);
// Uint8Array [ 1, 2, 3 ]

// String
// Int16Array [ 1, 2, 3 ]

// Using an arrow function as the map function to
// manipulate the elements
Float32Array.from([1, 2, 3], x => x + x);
// Float32Array [ 2, 4, 6 ]

// Generate a sequence of numbers
Uint8Array.from({length: 5}, (v, k) => k);
// Uint8Array [ 0, 1, 2, 3, 4 ]


You can partially work around this by inserting the following code at the beginning of your scripts, allowing use of much of the functionality of from() in implementations that do not natively support it.

if (!Int8Array.__proto__.from) {
    (function () {
        Int8Array.__proto__.from = function (obj, func, thisObj) {

            var typedArrayClass = Int8Array.__proto__;
            if(typeof this !== 'function') {
                throw new TypeError('# is not a constructor');
            if (this.__proto__ !== typedArrayClass) {
                throw new TypeError('this is not a typed array.');
            func = func || function (elem) {
                    return elem;

            if (typeof func !== 'function') {
                throw new TypeError('specified argument is not a function');

            obj = Object(obj);
            if (!obj['length']) {
                return new this(0);
            var copy_data = [];
            for(var i = 0; i < obj.length; i++) {

            copy_data = copy_data.map(func, thisObj);

            var typed_array = new this(copy_data.length);
            for(var i = 0; i < typed_array.length; i++) {
                typed_array[i] = copy_data[i];
            return typed_array;


Specification Status Comment
ECMAScript Latest Draft (ECMA-262)
The definition of '%TypedArray%.from' in that specification.
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of '%TypedArray%.from' in that specification.
Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
fromChrome Full support 45Edge Full support 14Firefox Full support 38IE No support NoOpera No support NoSafari Full support 10WebView Android No support NoChrome Android No support NoFirefox Android Full support 38Opera Android No support NoSafari iOS Full support 10Samsung Internet Android No support Nonodejs Full support 4.0.0


Full support  
Full support
No support  
No support

See also