Javascript Uint8ClampedArray forEach()

Introduction

The Javascript Uint8ClampedArray forEach() method executes a provided function on each array element.

This method works the same as Array.prototype.forEach().

Uint8ClampedArray.forEach(callback[, thisArg])
Parameter
Optional
Meaning
callback




Required




Function that produces an element of the new typed array,
Taking three arguments:
currentValue - the current element being processed.
index - the index of the current element.
array - the array itself.
thisArg
Optional
Value to use as this when executing callback.

The following code logs a line for each element in a typed array:

function logArrayElements(element, index, array) {
  console.log('a[' + index + '] = ' + element);
}

new Uint8ClampedArray([0, 1, 2, 3]).forEach(logArrayElements);



PreviousNext

Related