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.

La propiedad de acceso byteLength representa la longitud de ArrayBuffer en bytes.

Pruébalo

// 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

Sintaxis

arraybuffer.byteLength

Descripción

La propiedad byteLength es una propiedad de acceso cuya función de acceso de conjunto es undefined, lo que significa que solo puede leer esta propiedad. El valor se establece cuando la matriz se construye y no se puede cambiar. Esta propiedad devuelve 0 si este ArrayBuffer ha sido separado.

Ejemplos

js
var buffer = new ArrayBuffer(8);
buffer.byteLength; // 8

Especificaciones

Specification
ECMAScript® 2025 Language Specification
# sec-get-arraybuffer.prototype.bytelength

Compatibilidad con navegadores

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
byteLength

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Ver también