Returns the largest numeric value produced for the elements in the sequence.
Type of elements within the source iterable.
source
The source iterable.
Optional
Optional projection that extracts the numeric value for each element. Defaults to the element itself.
The maximum of the projected values.
Thrown when the sequence is empty.
The entire sequence is enumerated exactly once. Provide a selector when the elements are not already numeric.
const numbers = [1, 5, 2, 4, 3];const maxNumber = max(numbers);console.log(maxNumber); // 5const people = [ { name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Charlie', age: 28 },];const maxAge = max(people, p => p.age);console.log(maxAge); // 30 Copy
const numbers = [1, 5, 2, 4, 3];const maxNumber = max(numbers);console.log(maxNumber); // 5const people = [ { name: 'Alice', age: 25 }, { name: 'Bob', age: 30 }, { name: 'Charlie', age: 28 },];const maxAge = max(people, p => p.age);console.log(maxAge); // 30
Returns the largest numeric value produced for the elements in the sequence.