TypedArray.prototype.byteLength
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ì.
byteLength ì ê·¼ì ìì±ì íìí ë°°ì´ì 길ì´(ë°ì´í¸)를 ëíë
ëë¤.
ìëí´ ë³´ê¸°
// 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ë TypedArray ê°ì²´ ì¤ íëì
ëë¤.
ìì
>byteLength ìì± ì¬ì©í기
js
const buffer = new ArrayBuffer(8);
const uint8 = new Uint8Array(buffer);
uint8.byteLength; // 8 (bufferì byteLengthì ì¼ì¹)
const uint8newLength = new Uint8Array(buffer, 1, 5);
uint8newLength.byteLength; // 5 (Uint8Array를 ë§ë¤ ë ì§ì ë ëë¡)
const uint8offSet = new Uint8Array(buffer, 2);
uint8offSet.byteLength; // 6 (ìì±ë Uint8Arrayì ì¤íì
ì¼ë¡ ì¸í´)
ëª ì¸ì
| Specification |
|---|
| ECMAScript® 2027 Language Specification > # sec-get-%typedarray%.prototype.bytelength > |