Skip to content

maxBy

maxBy<T>(iterable, valueOf): T | null

Defined in: select/max-by.ts:15

Returns the item with the largest valueOf(item), or null if the iterable is empty. Ties resolve to the first item seen.

Time complexity: O(n), with one valueOf call per item.

T

Iterable<T>

The input iterable.

Callable<[T], number>

Numeric key extractor.

T | null

The maximum item, or null for an empty iterable.