TypedArray.of()
 The TypedArray.of() method creates a new typed array from a variable number of arguments. This method is nearly the same as Array.of(). 
Syntax
TypedArray.of(element0) TypedArray.of(element0, element1) TypedArray.of(element0, element1, ... , elementN)
Where TypedArray is one of:
- Int8Array
- Uint8Array
- Uint8ClampedArray
- Int16Array
- Uint16Array
- Int32Array
- Uint32Array
- Float32Array
- Float64Array
- BigInt64Array
- BigUint64Array
Parameters
- elementN
-  Elements of which to create the typed array. 
Return value
A new TypedArray instance.
Description
 Some subtle distinctions between Array.of() and TypedArray.of(): 
-  If the thisvalue passed toTypedArray.of()is not a constructor,TypedArray.of()will throw aTypeError, whereArray.of()defaults to creating a newArray.
-  TypedArray.of()uses[[Put]]whereArray.of()uses[[DefineProperty]]. Hence, when working withProxyobjects, it callshandler.setto create new elements rather thanhandler.defineProperty().
Examples
Using of()
Uint8Array.of(1); // Uint8Array [ 1 ] Int8Array.of('1', '2', '3'); // Int8Array [ 1, 2, 3 ] Float32Array.of(1, 2, 3); // Float32Array [ 1, 2, 3 ] Int16Array.of(undefined); // Int16Array [ 0 ]
Specifications
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
| of | 45 | 14 | 38 | No | No | 9.1 | No | No | 38 | No | 9.3 | No | 
See also
- A polyfill of TypedArray.ofis available incore-js
- TypedArray.from()
- Array.of()
    © 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of