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