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.
byteLength
アクセサープロパティは、ArrayBuffer
の長さをバイト単位で表します。
試してみましょう
// 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
解説
byteLength
プロパティはアクセサープロパティで、設定アクセサー関数が undefined
であるため、このプロパティは読み取ることしかできません。値は配列が構築されるときに設定され、変更することができません。この ArrayBuffer
が取り外された場合、このプロパティは 0 を返します。
例
byteLength の使用
js
const buffer = new ArrayBuffer(8);
buffer.byteLength; // 8
仕様書
Specification |
---|
ECMAScript® 2025 Language Specification # sec-get-arraybuffer.prototype.bytelength |
ブラウザーの互換性
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
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.