Javascript Uint8ClampedArray byteLength

Introduction

The Javascript Uint8ClampedArray byteLength property returns the length in bytes of a typed array.

Uint8ClampedArray.byteLength

The Javascript Uint8ClampedArray byteLength property is a read only property.

The value is set when a Uint8ClampedArray is created and cannot be changed.

If the Uint8ClampedArray is not specifying an byteOffset or a length, the length of the referenced ArrayBuffer will be returned.

Using the Javascript Uint8ClampedArray byteLength property

var buffer = new ArrayBuffer(8);

var uint8 = new Uint8ClampedArray(buffer);
console.log(uint8.byteLength); // 8 (matches the byteLength of the buffer)

var uint8 = new Uint8ClampedArray(buffer, 1, 5);
console.log(uint8.byteLength); // 5 (as specified when constructing the Uint8ClampedArray)

var uint8 = new Uint8ClampedArray(buffer, 2);
console.log(uint8.byteLength); // 6 (due to the offset of the constructed Uint8ClampedArray)



PreviousNext

Related