Javascript Uint8ClampedArray reduceRight()

Introduction

The Javascript Uint8ClampedArray reduceRight() method reduce Uint8ClampedArray via provided function from right-to-left.

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

Uint8ClampedArray.reduceRight(callback[, initialValue])
Parameter
Optional
Meaning
callback





Required





Function to execute on each value in the typed array
Taking four arguments:
initialValue - the value returned in the last invocation, or initialValue, if supplied.
currentValue - the current element being processed.
index - the index of the current element being processed.
array - the typed array itself.
initialValue
Optional
Object to use as the first argument to the first call of the callback.

Sum up all values within an array

var total = new Uint8ClampedArray([0, 1, 2, 3]).reduceRight(function(a, b) {
  return a + b;//w  w  w. j a  va  2s  .c o m
});
console.log(total);



PreviousNext

Related