Skip to content

max() function

Returns the largest of the given iterable/AsyncIterable

Signature:

typescript
declare function max<A extends Iterable<number> | AsyncIterable<number>>(iterable: A): ReturnValueType<A, number>;

Example

ts
max([1, 3, 5]); // 5;
max([1, NaN, 2]); // NaN;
max([1, Infinity, 2]); // Infinity;
max([]); // -Infinity

Open Source Code

Released under the Apache-2.0 License.