UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ TypedArray/ TypedArray.prototype.reduceRight()

The 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 Array.prototype.reduceRight.

Syntax

reduceRight(callbackFn)
reduceRight(callbackFn, initialValue)

Parameters

Return value

The value that results from the reduction.

Description

See Array.prototype.reduceRight for more details. This method is not generic and can only be called on typed array instances.

Examples

Sum up all values within an array

const total = new Uint8Array([0, 1, 2, 3]).reduceRight((a, b) => a + b);
// total === 6

Specifications

Browser compatibility

See also