The max() is a static method of Math, therefore, it is always used as Math.max(), rather than as a method of a Math object created.
Math.max(value1, value2, ...)
Parameters: This method accepts a single parameter that can be used n number of times as mentioned above and described below:
- value: These values are sent to math.max() method for finding the largest.
Return values: The Math.max() method returns the largest of the given numbers.
Below is an example of the Math max() method.
When positive numbers are passed as parameters: 32
Example 2 : When negative numbers are passed as parameters.
Result : -1
Example 3: When no parameters are passed.
Result : -Infinity
Example 4: When NaN is passed as a parameter.
Result : NaN
- Google Chrome 1 and above
- Internet Explorer 3 and above
- Firefox 1 and above
- Opera 3 and above
- Safari 1 and above
Please Login to comment...