4.17.11
3.10.1
2.4.2
1.3.1

_.reduceRight(collection, [iteratee=_.identity], [accumulator])

This method is like _.reduce except that it iterates over elements of collection from right to left.

Since

0.1.0

Arguments

argument
collection
[iteratee=_.identity]
[accumulator]
type
(Array|Object)
Function
*
description
The collection to iterate over.
The function invoked per iteration.
The initial value.

Returns

(array)

Example

var array = [
  [0, 1],
  [2, 3],
  [4, 5],
];

_.reduceRight(
  array,
  function (flattened, other) {
    return flattened.concat(other);
  },
  []
);
// => [4, 5, 2, 3, 0, 1]
var array = [
  [0, 1],
  [2, 3],
  [4, 5],
];

_.reduceRight(
  array,
  function (flattened, other) {
    return flattened.concat(other);
  },
  []
);
// => [4, 5, 2, 3, 0, 1]