Typed arrays (initial support)
Typed arrays are ordered lists of JavaScript values, where all values are of the same numerical type, such as 8-bit integers or 32-bit floating point numbers.
Overview
Typed arrays are ordered lists of JavaScript values, where all values are of the same numerical type, such as 8-bit integers or 32-bit floating point numbers.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 7 | 12 | 4 | 5.1 | 18 | 4.2 | |
| The ArrayBuffer[Symbol.species] static accessor property returns the constructor used to construct return values from array buffer methods. | 51 | 13 | 48 | 10 | 51 | 10 |
| The ArrayBuffer() constructor creates ArrayBuffer objects. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The byteLength accessor property of ArrayBuffer instances returns the length (in bytes) of this array buffer. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The ArrayBuffer.isView() static method determines whether the passed value is one of the ArrayBuffer views, such as typed array objects or a DataView. | 32 | 12 | 29 | 7 | 32 | 7 |
| The slice() method of ArrayBuffer instances returns a new ArrayBuffer whose contents are a copy of this ArrayBuffer's bytes from start, inclusive, up to end, exclusive. If either start or end is negative, it refers to an index from the end of the array, as opposed to from the beginning. | 17 | 12 | 12 | 5.1 | 18 | 6 |
| Other | ||||||
| The DataView view provides a low-level interface for reading and writing multiple number types in a binary ArrayBuffer, without having to care about the platform's endianness. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| Built-in object | ||||||
| The DataView() constructor creates DataView objects. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The buffer accessor property of DataView instances returns the ArrayBuffer or SharedArrayBuffer referenced by this view at construction time. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The byteLength accessor property of DataView instances returns the length (in bytes) of this view. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The byteOffset accessor property of DataView instances returns the offset (in bytes) of this view from the start of its ArrayBuffer or SharedArrayBuffer. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getFloat32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getFloat64() method of DataView instances reads 8 bytes starting at the specified byte offset of this DataView and interprets them as a 64-bit floating point number. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getInt16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getInt32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit signed integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getInt8() method of DataView instances reads 1 byte at the specified byte offset of this DataView and interprets it as an 8-bit signed integer. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getUint16() method of DataView instances reads 2 bytes starting at the specified byte offset of this DataView and interprets them as a 16-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getUint32() method of DataView instances reads 4 bytes starting at the specified byte offset of this DataView and interprets them as a 32-bit unsigned integer. There is no alignment constraint; multi-byte values may be fetched from any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The getUint8() method of DataView instances reads 1 byte at the specified byte offset of this DataView and interprets it as an 8-bit unsigned integer. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setFloat32() method of DataView instances takes a number and stores it as a 32-bit floating point number in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setFloat64() method of DataView instances takes a number and stores it as a 64-bit floating point number in the 8 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setInt16() method of DataView instances takes a number and stores it as a 16-bit signed integer in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setInt32() method of DataView instances takes a number and stores it as a 32-bit signed integer in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setInt8() method of DataView instances takes a number and stores it as an 8-bit signed integer in the byte at the specified byte offset of this DataView. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setUint16() method of DataView instances takes a number and stores it as a 16-bit unsigned integer in the 2 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setUint32() method of DataView instances takes a number and stores it as a 32-bit unsigned integer in the 4 bytes starting at the specified byte offset of this DataView. There is no alignment constraint; multi-byte values may be stored at any offset within bounds. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| The setUint8() method of DataView instances takes a number and stores it as an 8-bit unsigned integer in the byte at the specified byte offset of this DataView. | 9 | 12 | 15 | 5.1 | 18 | 5 |
| Other | ||||||
| The Float32Array typed array represents an array of 32-bit floating point numbers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard… | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Float32Array() constructor creates Float32Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Float32Array.Float32Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Float32Array.Float32Array.iterable allowed `new Float32Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| The Float64Array typed array represents an array of 64-bit floating point numbers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard… | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Float64Array() constructor creates Float64Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Float64Array.Float64Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Float64Array.Float64Array.iterable allowed `new Float64Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| The Int16Array typed array represents an array of 16-bit signed integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array… | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Int16Array() constructor creates Int16Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Int16Array.Int16Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Int16Array.Int16Array.iterable allowed `new Int16Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| The Int32Array typed array represents an array of 32-bit signed integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array… | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Int32Array() constructor creates Int32Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Int32Array.Int32Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Int32Array.Int32Array.iterable allowed `new Int32Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| The Int8Array typed array represents an array of 8-bit signed integers. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Int8Array() constructor creates Int8Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Int8Array.Int8Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Int8Array.Int8Array.iterable allowed `new Int8Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| A TypedArray object describes an array-like view of an underlying binary data buffer. There is no global property named TypedArray, nor is there a directly visible TypedArray constructor. Instead, there are a number of different global properties, whose values are typed array constructors for specific element types, listed below. On the following pages you… | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The TypedArray[Symbol.species] static accessor property returns the constructor used to construct return values from typed array methods. | 51 | 13 | 48 | 10 | 51 | 10 |
| The TypedArray.BYTESPERELEMENT static data property represents the size in bytes of each element in a typed array. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The buffer accessor property of TypedArray instances returns the ArrayBuffer or SharedArrayBuffer referenced by this typed array at construction time. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The byteLength accessor property of TypedArray instances returns the length (in bytes) of this typed array. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The byteOffset accessor property of TypedArray instances returns the offset (in bytes) of this typed array from the start of its ArrayBuffer or SharedArrayBuffer. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
TypedArray.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
TypedArray.index properties not consulting prototype Indexed properties not consulting prototype | 7 | 12 | 25 | 5.1 | 18 | 5 |
TypedArray.iterable in constructor Iterable in constructor | 39 | 14 | 52 | 10 | 39 | 10 |
| The join() method of TypedArray instances creates and returns a new string by concatenating all of the elements in this typed array, separated by commas or a specified separator string. If the typed array has only one item, then that item will be returned without using the separator. This method has the same algorithm as Array.prototype.join(). | 45 | 12 | 37 | 10 | 45 | 10 |
| The length accessor property of TypedArray instances returns the length (in elements) of this typed array. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The name data property of a Function instance indicates the function's name as specified when it was created, or it may be either anonymous or '' (an empty string) for functions created anonymously. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
TypedArray.named properties Named properties | 7 | 12 | 30 | 5.1 | 18 | 5 |
| The reverse() method of TypedArray instances reverses a typed array in place and returns the reference to the same typed array, the first typed array element now becoming the last, and the last typed array element becoming the first. In other words, elements order in the typed array will be turned towards the direction opposite to that previously stated.… | 45 | 12 | 37 | 10 | 45 | 10 |
| The set() method of TypedArray instances stores multiple values in the typed array, reading input values from a specified array. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The slice() method of TypedArray instances returns a copy of a portion of a typed array into a new typed array object selected from start to end (end not included) where start and end represent the index of items in that typed array. The original typed array will not be modified. This method has the same algorithm as Array.prototype.slice(). | 45 | 12 | 38 | 10 | 45 | 10 |
| The sort() method of TypedArray instances sorts the elements of a typed array in place and returns the reference to the same typed array, now sorted. This method has the same algorithm as Array.prototype.sort(), except that it sorts the values numerically instead of as strings by default. | 45 | 12 | 46 | 10 | 45 | 10 |
| The subarray() method of TypedArray instances returns a new typed array on the same ArrayBuffer store and with the same element types as for this typed array. The begin offset is inclusive and the end offset is exclusive. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| The toString() method of TypedArray instances returns a string representing the specified typed array and its elements. This method has the same algorithm as Array.prototype.toString(). | 7 | 12 | 51 | 5.1 | 18 | 5 |
| Other | ||||||
| The Uint16Array typed array represents an array of 16-bit unsigned integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array… | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Uint16Array() constructor creates Uint16Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Uint16Array.Uint16Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Uint16Array.Uint16Array.iterable allowed `new Uint16Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| The Uint32Array typed array represents an array of 32-bit unsigned integers in the platform byte order. If control over byte order is needed, use DataView instead. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array… | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Uint32Array() constructor creates Uint32Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Uint32Array.Uint32Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Uint32Array.Uint32Array.iterable allowed `new Uint32Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| The Uint8Array typed array represents an array of 8-bit unsigned integers. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Uint8Array() constructor creates Uint8Array objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Uint8Array.Uint8Array.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Uint8Array.Uint8Array.iterable allowed `new Uint8Array(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
| Other | ||||||
| The Uint8ClampedArray typed array represents an array of 8-bit unsigned integers clamped to 0–255. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation). | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
| Built-in object | ||||||
| The Uint8ClampedArray() constructor creates Uint8ClampedArray objects. The contents are initialized to 0 unless initialization data is explicitly provided. | 7 | 12 | 4 | 5.1 | 18 | 4.2 |
Uint8ClampedArray.Uint8ClampedArray.constructor without parameters Constructor without parameters | 7 | 12 | 55 | 5.1 | 18 | 5 |
Uint8ClampedArray.Uint8ClampedArray.iterable allowed `new Uint8ClampedArray(iterable)` | 39 | 14 | 52 | 10 | 39 | 10 |
- The non-standard `ArrayBuffer.slice()` method has been removed in Firefox 53 (but the standardized version `ArrayBuffer.prototype.slice()` is kept.
- Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
- Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
- Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
- Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
- Negative integers are not considered as indexed properties and therefore return the value of the prototype property.
Syntax
const buffer = new ArrayBuffer(16);
const int32 = new Int32Array(buffer);
int32[0] = 42;
const float64 = new Float64Array([1.5, 2.5, 3.5]);
float64.map(x => x * 2); // Float64Array [3, 5, 7] Live demo
bainaride-ta. Directlyoperation
ArrayBuffer middle, different type(Int8 and Int32) in display..
Notesrisize. Difference with type.
baitnumber that different and inspect it.. with sameelementnumber in also, Int8 and Float64.
col-de-ta. operation
Uint8ClampedArray Use, RGBA value that 0~255 to automaticallylimit variantchild inspect it..
Use cases
Using Typed arrays (initial support)
Typed arrays are ordered lists of JavaScript values, where all values are of the same numerical type, such as 8-bit integers or 32-bit floating point numbers.
Cautions
- No specific concerns. Stable across all major browsers.
Accessibility
- When updating the DOM dynamically, announce important changes to assistive technology with aria-live regions.
Related links
Powered by web-features