ArrayBuffer.prototype.byteLength
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
L'accesseur byteLength
est une propriété représentant la longueur d'un ArrayBuffer
en octets.
Exemple interactif
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
// Use byteLength to check the size
const bytes = buffer.byteLength;
console.log(bytes);
// Expected output: 8
Syntaxe
arraybuffer.byteLength;
Description
La propriété byteLength
est un accesseur dont le mutateur associé vaut undefined
. Cela signifie que cette propriété est en lecture seule. La valeur est déterminée lors de la construction du tableau et ne peut pas être changée par la suite. Cette propriété renvoie 0 si ce ArrayBuffer
a été détaché.
Exemples
var buffer = new ArrayBuffer(8);
buffer.byteLength; // 8
Spécifications
Specification |
---|
ECMAScript® 2025 Language Specification # sec-get-arraybuffer.prototype.bytelength |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
byteLength |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support