Favorites

JavaScript Array.prototype.reduceRight() Method

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Array.prototype.reduceRight()
JavaScript Array Instance methodThis method is supported by all modern browsers.
Updated 28th November 2026

The reduceRight() method works like reduce() but processes the array from the last element to the first.

Description

The reduceRight() method is the same as reduce(), but it walks the array from right to left. It's occasionally useful when the order matters, such as composing functions so that the last one runs first.

It takes the same callback as reduce(): the accumulator, the current element, its index and the array. With no initial value, the last element is used as the starting accumulator and the loop begins at the second-to-last element. Empty slots in sparse arrays are skipped.

For operations where order doesn't matter, such as summing numbers, reduceRight() and reduce() give the same result. It makes a difference when combining strings, building nested structures from the inside out, or composing functions, where the last function in the list should run first.

Syntax

array.reduceRight(callbackFn)
array.reduceRight(callbackFn, initialValue)

Parameters

  • callbackFnA function that combines the accumulator with each element, from right to left.
  • initialValueOptional. The starting value of the accumulator.

Return Value

The final value of the accumulator.

Exceptions

  • TypeErrorThrown if the array is empty and no initialValue is given.

Example

console.log(['a', 'b', 'c'].reduceRight((acc, s) => acc + s, ''));

const compose = (...fns) => x => fns.reduceRight((v, f) => f(v), x);
const addThenDouble = compose(n => n * 2, n => n + 1);
console.log(addThenDouble(5));

Browser Support

The following information will show you the current browser support for the Array.prototype.reduceRight() method. Hover over a browser icon to see the version that first introduced support for this method.

This method is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee