ArrayBuffer.prototype.resizable

Baseline 2024
Newly available

Since July 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

resizableArrayBuffer インスタンスのアクセサープロパティで、この ArrayBuffer がサイズ変更かどうかを表します。

試してみましょう

const buffer1 = new ArrayBuffer(8, { maxByteLength: 16 });
const buffer2 = new ArrayBuffer(8);

console.log(buffer1.resizable);
// Expected output: true

console.log(buffer2.resizable);
// Expected output: false

解説

resizable プロパティはアクセサープロパティであり、設定アクセサー関数が undefined であるためこのプロパティは読み取ることしかできません。この値は、この配列が構築されるときに確定されます。コンストラクターで maxByteLength オプションが設定されていれば resizabletrue を返し、そうでなければ false を返します。

resizable の使用

この例では、最大 16 バイトの長さにサイズ変更可能な 8 バイトのバッファーを作成し、resizable プロパティを調べて、resizable が true を返す場合にサイズ変更します。

js
const buffer = new ArrayBuffer(8, { maxByteLength: 16 });

if (buffer.resizable) {
  console.log("Buffer is resizable!");
  buffer.resize(12);
}

仕様書

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

ブラウザーの互換性

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
resizable

Legend

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

Full support
Full support
No support
No support

関連情報