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/TypedArray/byteLength below:

TypedArray.prototype.byteLength - JavaScript | MDN

TypedArray.prototype.byteLength

Baseline Widely available

byteLength は TypedArray のアクセサープロパティで、この型付き配列の長さを(バイト単位で)返します。

試してみましょう
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer, 2);

console.log(uint8.byteLength);
// Expected output: 6
解説

byteLength プロパティは設定アクセサープロパティが undefined である、読み取り専用のアクセサープロパティです。値は TypedArray が構築されたときに確立し、変更することができません。 TypedArray が byteOffset や length を指定していないなら、参照されている ArrayBuffer の length が返されます。 TypedArray は型付き配列オブジェクトのうちの一つです。

例 byteLength プロパティの使用
const buffer = new ArrayBuffer(8);

const uint8 = new Uint8Array(buffer);
uint8.byteLength; // 8 (matches the byteLength of the buffer)

const uint8newLength = new Uint8Array(buffer, 1, 5);
uint8newLength.byteLength; // 5 (as specified when constructing the Uint8Array)

const uint8offSet = new Uint8Array(buffer, 2);
uint8offSet.byteLength; // 6 (due to the offset of the constructed Uint8Array)
仕様書 ブラウザーの互換性 関連情報

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