• Just like array.reduce

    Example

    reduce({foo: 1, bar: 2}, (prev, value, key) => [...prev, key + ":" + value], []); // ["foo:1", "bar:2"]
    

    Type Parameters

    • T extends Record<string, unknown>

    • K extends string | number | symbol

    • P = unknown

    Parameters

    • obj: T
    • fn: ((prev: P, value: T[K], key: K, object: T) => P)
        • (prev: P, value: T[K], key: K, object: T): P
        • Parameters

          • prev: P
          • value: T[K]
          • key: K
          • object: T

          Returns P

    • Optional initialValue: P = ...

    Returns P

Generated using TypeDoc