[go: up one dir, main page]

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

TypedArray.prototype.buffer

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월⁩.

buffer 접근자 속성은 생성 시 TypedArray에서 참조하는 ArrayBuffer를 나타냅니다.

시도해 보기

// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(8);
const uint16 = new Uint16Array(buffer);

console.log(uint16.buffer.byteLength);
// Expected output: 8

설명

buffer 속성은 set 접근자 함수가 undefined인 속성으로, 이 속성은 읽을수만 있습니다. 값은 TypedArray가 생성될 때 설정되어 변경할 수 없습니다. TypedArrayTypedArray 객체 중 하나입니다.

예제

buffer 속성 사용하기

js
const buffer = new ArrayBuffer(8);
const uint16 = new Uint16Array(buffer);
uint16.buffer; // ArrayBuffer { byteLength: 8 }

잘린 배열 보기에서 기반 버퍼에 액세스하기

js
const buffer = new ArrayBuffer(1024);
const arr = new Uint8Array(buffer, 64, 128);
console.log(arr.byteLength); // 128
console.log(arr.buffer.byteLength); // 1024
console.log(arr.buffer === buffer); // true

명세서

Specification
ECMAScript® 2026 Language Specification
# sec-get-%typedarray%.prototype.buffer

브라우저 호환성

같이 보기