Function reduce

Applies a reducer function to each element of the array, resulting in a single value.

reduce(0, (acc: number, curr:) => acc + curr)([1, 2, 3]) // 6
  • Type Parameters

    • V
    • T

    Parameters

    • starter: V
    • reducer: ((acc: V, curr: T) => V)
        • (acc, curr): V
        • Parameters

          • acc: V
          • curr: T

          Returns V

    Returns ((source: readonly T[]) => V)

      • (source): V
      • Parameters

        • source: readonly T[]

        Returns V