reduceRight() method of
TypedArray instances applies a function against an accumulator and each value of the typed array (from right-to-left) to reduce it to a single value. This method has the same algorithm as
reduceRight(callbackFn) reduceRight(callbackFn, initialValue)
A function to execute for each element in the typed array. Its return value becomes the value of the
accumulatorparameter on the next invocation of
callbackFn. For the last invocation, the return value becomes the return value of
reduceRight(). The function is called with the following arguments:
The value resulting from the previous call to
callbackFn. On the first call, its value is
initialValueif the latter is specified; otherwise its value is the last element of the typed array.
The value of the current element. On the first call, its value is the last element if
initialValueis specified; otherwise its value is the second-to-last element.
The index position of
currentValuein the typed array. On the first call, its value is
array.length - 1if
initialValueis specified, otherwise
array.length - 2.
The typed array
reduceRight()was called upon.
Value to use as accumulator to the first call of the
callbackFn. If no initial value is supplied, the last element in the typed array will be used and skipped. Calling
reduceRight()on an empty typed array without an initial value creates a
The value that results from the reduction.
Array.prototype.reduceRight() for more details. This method is not generic and can only be called on typed array instances.
const total = new Uint8Array([0, 1, 2, 3]).reduceRight((a, b) => a + b); // total === 6
|ECMAScript Language Specification |
BCD tables only load in the browser