Javascript BigInt64Array reduce()

Introduction

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

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

BigInt64Array.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 BigInt64Array([0n, 1n, 2n, 3n]).reduce(function(a, b) {
  return a + b;/*  w  w  w .j  a v a2 s.  c om*/
});
console.log(total);



PreviousNext

Related