To get the largest of zero or more number in JavaScript, use the Math.max() method. If no arguments are given, the results are -Infinity.
Syntax
The following in the syntax −
Math.max(value1, value2, ... valueN ) ;
The parameter value1, value, … value N numbers.
Example
You can try to run the following code to get the largest of zero or more numbers −
<html>
<head>
<title>JavaScript Math max() Method</title>
</head>
<body>
<script>
var value = Math.max(24, 220, -80, 100);
document.write("First Value : " + value );
var value = Math.max(-10, -24, -98);
document.write("<br />Second Value : " + value );
var value = Math.max(0, -1);
document.write("<br />Third Value : " + value );
</script>
</body>
</html>