[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/length [Back]  [Original]

TypedArray.prototype.length - JavaScript | MDN

MDN Web Docs

View in English Always switch to English

TypedArray.prototype.length

20157

TypedArray length

// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer, 2);

console.log(uint8.length);
// Expected output: 6

length set undefined TypedArray TypedArray byteOffset length ArrayBuffer TypedArray TypedArray

length

js
const buffer = new ArrayBuffer(8);

let uint8 = new Uint8Array(buffer);
uint8.length; // 8 length 

uint8 = new Uint8Array(buffer, 1, 5);
uint8.length; // 5 Uint8Array 

uint8 = new Uint8Array(buffer, 2);
uint8.length; // 6 Uint8Array 

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


Web Proxy Viewer  |  New URL  |  Original Page