C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Math max() methodThe JavaScript math max() method compares the given numbers and returns the maximum value. SyntaxThe max() method is represented by the following syntax: Math.max(num1,num2,....,numN) Parameternum1,num2,....,numN - Numbers to be compared.. ReturnA maximum value of the given numbers. JavaScript Math max() method exampleHere, we will understand max() method through various examples. Example 1Let's see a simple example to print the maximum value of the given numbers. <script> document.writeln(Math.max(22,34,12,15)+"<br>"); document.writeln(Math.max(-10,-24,-12,-20)); </script> Output: 34 -10 Example 2Let's see an example to print the maximum value of the given array. <script> var arr=[13,15,12,9] document.writeln(Math.max(...arr)) </script> Output: 15
Next TopicJavaScript Math
|