Javascript Uint8ClampedArray copyWithin()

Introduction

The Javascript Uint8ClampedArray copyWithin() method copies the sub array.

This method works the same as Array copyWithin().

Uint8ClampedArray.copyWithin(target, start[, end = this.length])
Parameter Optional Meaning
targetRequired Target start index position where to copy the elements to.
start RequiredSource start index position where to start copying elements from.
end Optional Source end index position where to end copying elements from.
var buffer = new ArrayBuffer(8);
var uint8 = new Uint8ClampedArray(buffer);
uint8.set([1,2,3]);//from   w  w w  .  j av a 2 s .com
console.log(uint8); // Uint8ClampedArray [ 1, 2, 3, 0, 0, 0, 0, 0 ]
uint8.copyWithin(3,0,3);
console.log(uint8); // Uint8ClampedArray [ 1, 2, 3, 1, 2, 3, 0, 0 ]



PreviousNext

Related