Math.max( [ value1 ], [ value2 ], [ ... ] ) in ECMAScript 262
Return the largest of all arguments supplied.
Arguments
name | type | description |
---|---|---|
value1 | Number | [optional] The first value. |
value2 | Number | [optional] The second value. |
... | Number | [optional] etc. |
- Return Type
- Number
Description
If any of the arguments are not numbers, an attempt is made to convert them to numbers. If this attempt fails, the result will be NaN
.
var biggest = Math.max( 1 , 17 , '5', -0.4 , 18 , 3.1 );
// ** biggest is 18
var failedAttempt = Math.max( 10 , 'bee' );
// ** failedAttempt is NaN
If no arguments are supplied, the return value is Math.NEGATIVE_INFINITY
.