Uint8ClampedArray

The Uint8ClampedArray typed array represents an array of 8-bit unsigned integers clamped to 0-255; if you specified a value that is out of the range of [0,255], 0 or 255 will be set instead; if you specify a non-integer, the nearest integer will be set. The contents are initialized to 0. Once established, you can reference elements in the array using the object's methods, or using standard array index syntax (that is, using bracket notation).

Syntax

new Uint8ClampedArray(); // new in ES2017
new Uint8ClampedArray(length);
new Uint8ClampedArray(typedArray);
new Uint8ClampedArray(object);
new Uint8ClampedArray(buffer [, byteOffset [, length]]);

For more information about the constructor syntax and the parameters, see TypedArray.

Legend

Full support

Full support

No support

No support

Compatibility unknown

Compatibility unknown

Compatibility notes

Starting with ECMAScript 2015, Uint8ClampedArray constructors require to be constructed with a new operator. Calling a Uint8ClampedArray constructor as a function without new, will throw a TypeError from now on.