Javascript Uint8ClampedArray Type

Introduction

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

The constructors are listed as follows:

new Uint8ClampedArray();
new Uint8ClampedArray(length);
new Uint8ClampedArray(typedArray);
new Uint8ClampedArray(object);
new Uint8ClampedArray(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 Uint8ClampedArray.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 Int16Array(2);
int16[0] = 42;//ww  w .  ja v  a2  s  .com
console.log(int16[0]); // 42
Type Value Range Size in bytes DescriptionEquivalent C type
Uint8ClampedArray 0 to 255 1 8-bit unsigned integer (clamped) uint8_t



PreviousNext

Related