The TypedArray.BYTES_PER_ELEMENT property represents the size in bytes of each element in an typed array.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Property attributes of TypedArray.BYTES_PER_ELEMENT |
|
|---|---|
| Writable | no |
| Enumerable | no |
| Configurable | no |
Syntax
TypedArray.BYTES_PER_ELEMENT;
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
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 | Status | Comment |
|---|---|---|
| Typed Array Specification | Obsolete | Superseded by ECMAScript 6. |
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'TypedArray.BYTES_PER_ELEMENT' in that specification. |
Standard | Initial definition in an ECMA standard. |
| ECMAScript Latest Draft (ECMA-262) The definition of 'TypedArray.BYTES_PER_ELEMENT' in that specification. |
Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
BYTES_PER_ELEMENT | Chrome Full support 7 | Edge Full support Yes | Firefox Full support 4 | IE Full support 10 | Opera Full support 11.6 | Safari Full support 5.1 | WebView Android Full support 4 | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support 12 | Safari iOS Full support 4.2 | Samsung Internet Android Full support Yes | nodejs Full support Yes |
Legend
- Full support
- Full support