- reduce<T, K, P>(obj: T, fn: ((prev: P, value: T[K], key: K, object: T) => P), initialValue??: P): P
-
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
Just like array.reduce
Example