This page was translated from English by the community.Learn more and join the MDN Web Docs community.
TypedArray.prototype.length
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
TypedArray 인스턴스의length 접근자 속성은 이 형식화 배열의 요소의 수를 반환합니다.
In this article
시도해 보기
// Create an ArrayBuffer with a size in bytesconst buffer = new ArrayBuffer(8);const uint8 = new Uint8Array(buffer, 2);console.log(uint8.length);// Expected output: 6설명
length 속성은 설정된 접근자 함수가undefined인 접근자 속성으로, 이 속성을 읽을 수만 있습니다. 이 값은 TypedArray를 구성할 때 설정되며 변경할 수 없습니다. TypeArray에서byteOffset 또는length를 지정하지 않으면 참조된ArrayBuffer의 길이가 반환됩니다. TypeArray는TypeArray 객체 중 하나입니다.
예제
>length 속성 사용하기
js
const buffer = new ArrayBuffer(8);let uint8 = new Uint8Array(buffer);uint8.length; // 8 (버퍼의 길이와 일치)uint8 = new Uint8Array(buffer, 1, 5);uint8.length; // 5 (Uint8Array를 만들 때 지정된 대로)uint8 = new Uint8Array(buffer, 2);uint8.length; // 6 (만든 Uint8Array의 오프셋으로 인해)명세서
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-get-%typedarray%.prototype.length> |