Home > @i2analyze/notebook-sdk > data > IReadOnlyCollection > reduce
data.IReadOnlyCollection.reduce() method
Executes a reducer function on each object in the collection, to reduce it to a single object.
Signature:
reduce<U>(callbackfn: (previousValue: U, currentValue: V, currentIndex: number) => U, initialValue: U): U;
Introduced: version 1.0
Type Parameters
Parameter | Type | Description |
---|---|---|
U | any | The type of the single object. |
Parameters
Parameter | Type | Description |
---|---|---|
callbackfn | (previousValue: U, currentValue: V, currentIndex: number) => U | A function to apply against an accumulator and each object in the collection. |
initialValue | U | The single object to return, in its initial state. |
Returns:
U
An object that represents the reduced collection.