TypedArray.BYTES_PER_ELEMENT
The TypedArray.BYTES_PER_ELEMENT property represents the size in bytes of each element in a typed array.
Property attributes of TypedArray.BYTES_PER_ELEMENT |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
Description
TypedArray objects differ from each other in the number of bytes per element and in the way the bytes are interpreted. The BYTES_PER_ELEMENT constant contains the number of bytes each element in the given TypedArray has.
Examples
Using BYTES_PER_ELEMENT
Int8Array.BYTES_PER_ELEMENT; // 1
Uint8Array.BYTES_PER_ELEMENT; // 1
Uint8ClampedArray.BYTES_PER_ELEMENT; // 1
Int16Array.BYTES_PER_ELEMENT; // 2
Uint16Array.BYTES_PER_ELEMENT; // 2
Int32Array.BYTES_PER_ELEMENT; // 4
Uint32Array.BYTES_PER_ELEMENT; // 4
Float32Array.BYTES_PER_ELEMENT; // 4
Float64Array.BYTES_PER_ELEMENT; // 8
Specifications
| Specification |
|---|
| ECMAScript Language Specification # sec-typedarray.bytes_per_element |
Browser compatibility
BCD tables only load in the browser