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

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