JavaScript Math.max()
More Examples
let a = Math.max(5, 10);
let b = Math.max(0, 150, 30, 20, 38);
let c = Math.max(-5, 10);
let d = Math.max(-5, -10);
let e = Math.max(1.5, 2.5);
Try it Yourself »
Description
The Math.max()
method returns the number with the highest value.
See Also:
The Math.min() MethodSyntax
Math.max(n1, n2,...)
Parameters
Parameter | Description |
n1, n2,... | Optional. One or more numbers to compare. |
Return Value
Type | Description |
Number | The highest number of the arguments.-Infinity if no arguments are given.NaN if one of the arguments is not a number. |
Browser Support
Math.max()
is an ECMAScript1 (ES1) feature.
ES1 (JavaScript 1997) is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |