JavaScript max () method
Examples
Returns the specified number two in number with the larger value:
Math.max(5,10);
Output:
10
try it"
Definition and Usage
The number of large value of max () method returns with two specified numbers.
Browser Support
All major browsers support max () method
grammar
Math.max( n1 , n2 , n3 ,...,nX)
Parameter Value
参数 | 描述 |
---|---|
n1 , n2 , n3 ,...,nX | 可选。1 或多个值。在 ECMASCript v3 之前,该方法只有两个参数。 |
return value
类型 | 描述 |
---|---|
Number | 参数中最大的值。如果没有参数,则返回 -Infinity。如果有某个参数为 NaN,或是不能转换成数字的非数字值,则返回 NaN。 |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
In this example, we will show how to use the max () to return the specified number of digital with the highest values:
var a=Math.max(5,10);
var b=Math.max(0,150,30,20,38);
var c=Math.max(-5,10);
var d=Math.max(-5,-10);
var e=Math.max(1.5,2.5);
var b=Math.max(0,150,30,20,38);
var c=Math.max(-5,10);
var d=Math.max(-5,-10);
var e=Math.max(1.5,2.5);
a, b, c, d, and e output:
10
150
10
-5
2.5
150
10
-5
2.5
try it"