Function reduceRight

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

    Type Parameters

    • T

    • R

    Parameters

    • Optional collection: Record<string, T>

      The collection to iterate over.

      Optional
    • Optional iteratee: AccCollectionIteratee<T, R>

      The function invoked per iteration.

      Optional
    • Optional accumulator: R

      The initial value.

      Optional

    Returns R

    Returns the accumulated value.

    Since

    5.12.0

    See

    [[reduce]]

    Example

    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

    • Optional collection: ArrayLike<T>
      Optional
    • Optional iteratee: AccCollectionIteratee<T, R>
      Optional
    • Optional accumulator: R
      Optional

    Returns R