W3cubDocs

/JavaScript

TypedArray.BYTES_PER_ELEMENT

The TypedArray.BYTES_PER_ELEMENT property represents the size in bytes of each element in a typed array.

Try it

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
BigInt64Array.BYTES_PER_ELEMENT;     // 8
BigUint64Array.BYTES_PER_ELEMENT;    // 8

Specifications

Browser compatibility

Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet Deno Node.js
BYTES_PER_ELEMENT
7
12
4
10
11.6
5.1
4
18
4
12
4.2
1.0
1.0
0.10.0

See also

© 2005–2022 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/BYTES_PER_ELEMENT