Math max() method
JavaScript Math max() method
Last Updated : 17 Mar 2025
The JavaScript math max() method compares the given numbers and returns the maximum value.
Syntax
The max() method is represented by the following syntax:
Parameter
num1,num2,....,numN - Numbers to be compared..
Return
A maximum value of the given numbers.
JavaScript Math max() method example
Here, we will understand max() method through various examples.
Example 1
Let's see a simple example to print the maximum value of the given numbers.
Output:
Example 2
Let's see an example to print the maximum value of the given array.
Output: