This method is like reduce except that it iterates over elements of collection from right to left.
reduce
collection
Optional
The collection to iterate over.
The function invoked per iteration.
The initial value.
Returns the accumulated value.
5.12.0
[[reduce]]
const array = [[0, 1], [2, 3], [4, 5]]reduceRight(array, (flattened, other) => flattened.concat(other), [])// => [4, 5, 2, 3, 0, 1] Copy
const array = [[0, 1], [2, 3], [4, 5]]reduceRight(array, (flattened, other) => flattened.concat(other), [])// => [4, 5, 2, 3, 0, 1]
This method is like
reduce
except that it iterates over elements ofcollection
from right to left.