JavaScript (ES2026) reference · Array Methods

JavaScript Array reduceRight() Method

Like reduce(), but processes the array from the last element to the first.

JavaScript (ES2026) Since ES5

Syntax

array.reduceRight(callbackFn, initialValue)

Parameters

ParameterDescription
callbackFn Called with (accumulator, element, index, array).
initialValue optional The starting accumulator.

Return value

The final accumulator value.

Examples

Right to leftTry it yourself
console.log(["a", "b", "c"].reduceRight((acc, x) => acc + x, ""));

Output

cba
Compose functionsTry it yourself
const compose = (...fns) => (x) => fns.reduceRight((v, f) => f(v), x);
const inc = (n) => n + 1, double = (n) => n * 2;
console.log(compose(inc, double)(5)); // inc(double(5))

Output

11

Version history

VersionChange
JavaScript ES5Added