Math.max()

ES1+

Returns the largest of the zero or more numbers given as input parameters.

Syntax

Math.max(value1, value2, ...)

Parameters

values number

Zero or more numbers

Return Value

number

The largest of the given numbers, or -Infinity if no arguments

Examples

JavaScript
console.log(Math.max(1, 3, 2));
console.log(Math.max(-1, -3, -2));
console.log(Math.max(...[4, 5, 6]));
Output:
// 3 -1 6

Related Methods