Javascript Uint32Array reduce()

Introduction

The Javascript Uint32Array reduce() method Uint32Array to a single value.

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

Uint32Array.reduce(callback[, initialValue])
Parameter
Optional
Meaning
callback





Required





Function to execute on each value
Taking four arguments:
initialValue - the value returned in the last invocation.
currentValue - the current element.
index - the index of the current element.
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 Uint32Array([0, 1, 2, 3]).reduce(function(a, b) {
  return a + b;/*from  ww w . j  ava2s. c o  m*/
});
console.log(total);



PreviousNext

Related