A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/resizable below:

ArrayBuffer.prototype.resizable - JavaScript | MDN

ArrayBuffer.prototype.resizable

Baseline 2024

Newly available

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

resizable は ArrayBuffer インスタンスのアクセサープロパティで、この 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 オプションが設定されていれば resizable は true を返し、そうでなければ false を返します。

例 resizable の使用

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

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

if (buffer.resizable) {
  console.log("Buffer is resizable!");
  buffer.resize(12);
}
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4