[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/byteLength [Back]  [Original]

TypedArray.prototype.byteLength - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

TypedArray.prototype.byteLength

Baseline

20157

byteLength TypedArray

// ArrayBuffer 
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer, 2);

console.log(uint8.byteLength);
// : 6

byteLength undefined byteLength 0

byteLength

js
const buffer = new ArrayBuffer(8);

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

const uint8newLength = new Uint8Array(buffer, 1, 5);
uint8newLength.byteLength; // 5 Uint8Array 

const uint8offset = new Uint8Array(buffer, 2);
uint8offset.byteLength; // 6  Uint8Array 

const buffer2 = new ArrayBuffer(16, { maxByteLength: 32 });
const uint8lengthTracking = new Uint8Array(buffer2, 4);
uint8lengthTracking.byteLength; // 12 (16 - 4)
buffer2.resize(20);
uint8lengthTracking.byteLength; // 16 (20 - 4)
buffer2.resize(3);
uint8lengthTracking.byteLength; // 0 

ECMAScript 2027 LanguageSpecification
# sec-get-%typedarray%.prototype.bytelength


Web Proxy Viewer  |  New URL  |  Original Page