| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/of | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since September 2016.
The TypedArray.of() static method creates a new
typed array from a variable number of arguments. This method is nearly the same as
Array.of().
const int16array = Int16Array.of("10", "20", "30", "40", "50");
console.log(int16array);
// Expected output: Int16Array [10, 20, 30, 40, 50]
TypedArray.of()
TypedArray.of(element1)
TypedArray.of(element1, element2)
TypedArray.of(element1, element2, /* , */ elementN)
Where TypedArray is one of:
Int8ArrayUint8ArrayUint8ClampedArrayInt16ArrayUint16ArrayInt32ArrayUint32ArrayFloat16ArrayFloat32ArrayFloat64ArrayBigInt64ArrayBigUint64Arrayelement1, , elementNElements used to create the typed array.
A new TypedArray instance.
See Array.of() for more details. There are some subtle distinctions between Array.of() and
TypedArray.of():
this value passed to TypedArray.of() is not a constructor, TypedArray.of() will throw a TypeError, while Array.of() defaults to creating a new Array.TypedArray.of() uses [[Set]] while Array.of() uses [[DefineOwnProperty]]. Hence, when working with Proxy objects, it calls handler.set() to create new elements rather than handler.defineProperty().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 ]
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-%typedarray%.of |
TypedArray.of in core-jsTypedArrayTypedArray.from()Array.of()This page was last modified on Jul 10, 2025 by MDN contributors.
TypedArrayObject/FunctionBigInt64ArrayBigUint64ArrayFloat16ArrayFloat32ArrayFloat64ArrayInt8ArrayInt16ArrayInt32ArrayUint8ArrayUint8ClampedArrayUint16ArrayUint32ArrayYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |