Function reduceRight

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

    Type Parameters

    • T
    • R

    Parameters

    • Optionalcollection: Record<string, T>

      The collection to iterate over.

    • Optionaliteratee: AccCollectionIteratee<T, R>

      The function invoked per iteration.

    • Optionalaccumulator: R

      The initial value.

    Returns R

    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]
  • Type Parameters

    • T
    • R

    Parameters

    • Optionalcollection: ArrayLike<T>
    • Optionaliteratee: AccCollectionIteratee<T, R>
    • Optionalaccumulator: R

    Returns R