Javascript Uint16Array Type

Introduction

A Uint16Array object describes an array-like view of an underlying binary data buffer.

The constructors are listed as follows:

new Uint16Array();
new Uint16Array(length);
new Uint16Array(typedArray);
new Uint16Array(object);
new Uint16Array(buffer [, byteOffset [, length]]);
Parameter Optional Meaning
length Requiredan internal array buffer is created of size length multiplied by BYTES_PER_ELEMENT bytes.
typedArrayRequiredthe typedArray is copied into a new typed array.
object Requireduse the Uint16Array.from() method.
buffer Required create from buffer
byteOffset optional offset to start
length optionallength to copy

Property access

You can reference elements in the array using standard array index syntax.

var int16 = new Uint16Array(2);
int16[0] = 42;/*from   ww  w  .j  a  v  a2s. co  m*/
console.log(int16[0]); // 42
Type Value Range Size in bytes Description Equivalent C type
Uint16Array 0 to 65535 2 16-bit unsigned integer uint16_t



PreviousNext

Related