Uint16Array
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ìâ©.
Uint16Array íìí ë°°ì´(TypedArray)ì íë«í¼ì ë°ì´í¸ ìì를 ë°ë¥´ë 16ë¹í¸ ë¶í¸ ìë ì ìì ë°°ì´ì
ëíë
ëë¤. ë°ì´í¸ ìì를 ì ì´í´ì¼ íë ê²½ì° ëì DataView를 ì¬ì©í©ëë¤. ë°°ì´ì ë´ì©ì 0ì¼ë¡ ì´ê¸°íë©ëë¤.
ë°°ì´ì´ ìì±ëë©´ ê°ì²´ì ë©ìë를 ì¬ì©íê±°ë íì¤ ë°°ì´ ì¸ë±ì¤ 구문(ì¦, ëê´í¸ íê¸°ë² ì¬ì©)ì ì¬ì©íì¬ ë°°ì´ì ìì를 참조í ì ììµëë¤.
ìì±ì
Uint16Array()-
ìë¡ì´
Uint16Arrayê°ì²´ë¥¼ ìì±í©ëë¤.
ì ì ìì±
ë¶ëª¨ TypedArrayìì ì ì ìì±ì ììí©ëë¤.
Uint16Array.BYTES_PER_ELEMENT-
ìì í¬ê¸°ë¥¼ ì«ì ê°ì¼ë¡ ë°íí©ëë¤.
Uint16Arrayì ê²½ì°2ì ëë¤. Uint16Array.name-
ìì±ì ì´ë¦ì 문ìì´ë¡ ë°íí©ëë¤.
Uint16Arrayíì ì ê²½ì°"Uint16Array"ì ëë¤.
ì ì ë©ìë
ë¶ëª¨ TypedArrayìì ì ì ë©ìë를 ììí©ëë¤.
ì¸ì¤í´ì¤ ìì±
ë¶ëª¨ TypedArrayìì ì¸ì¤í´ì¤ ìì±ì ììí©ëë¤.
Uint16Array.prototype.BYTES_PER_ELEMENT-
ìì í¬ê¸°ë¥¼ ì«ì ê°ì¼ë¡ ë°íí©ëë¤.
Uint16Arrayì ê²½ì°2ì ëë¤.
ì¸ì¤í´ì¤ ë©ìë
ë¶ëª¨ TypedArrayìì ì¸ì¤í´ì¤ ë©ìë를 ììí©ëë¤.
ìì
>Uint16Array를 ìì±í기 ìí ê°ê¸° ë¤ë¥¸ ì¬ë¬ ë°©ë²
// 길ì´ë¡ë¶í° ìì±
const uint16 = new Uint16Array(2);
uint16[0] = 42;
console.log(uint16[0]); // 42
console.log(uint16.length); // 2
console.log(uint16.BYTES_PER_ELEMENT); // 2
// ë°°ì´ë¡ë¶í° ìì±
const x = new Uint16Array([21, 31]);
console.log(x[1]); // 31
// ë¤ë¥¸ TypedArrayë¡ë¶í° ìì±
const y = new Uint16Array(x);
console.log(y[0]); // 21
// ArrayBufferë¡ë¶í° ìì±
const buffer = new ArrayBuffer(16);
const z = new Uint16Array(buffer, 2, 4);
console.log(z.byteOffset); // 2
// ìíë¡ë¶í° ìì±
const iterable = (function* () {
yield* [1, 2, 3];
})();
const uint16FromIterable = new Uint16Array(iterable);
console.log(uint16FromIterable);
// Uint16Array [1, 2, 3]
ëª ì¸ì
| Specification |
|---|
| ECMAScript® 2026 Language Specification > # sec-typedarray-objects > |