Math.min( ) In JavaScript
The Math.min() function is used to return the lowest-valued number passed in the function. The Math.min() function returns NaN if any parameter isn’t a number and can’t be converted into one. The min() is a static method of Math, therefore, it is always used as Math.min(), rather than as a method of a Math object created.
Syntax:
Math.min(value1, value2, ...)
Parameters: This function accepts Value1,Value2 Values sent to math.min() function for finding the lowest-valued number.
Return Value: The Math.min() function returns the smallest of the given numbers.
Examples:
Input : Math.min(10, 32, 2)
Output : 2
Input : Math.min(-10, -32, -1)
Output : -32
Input : Math.min()
Output : -Infinity
Input : Math.min(10,2,NaN)
Output : NaN
Let’s see some JavaScript code on this function:
<script type="text/javascript"> document.write("Output : " + Math.min(10, 32, 2)); </script> |
Output:
Output : 2
<script type="text/javascript"> document.write("Output : " + Math.min(-10, -32, -1)); </script> |
Output:
Output : -32
<script type="text/javascript"> document.write("Output : " + Math.min()); </script> |
Output:
Output : -Infinity
<script type="text/javascript"> document.write("Output : " + Math.min(10,2,NaN)); </script> |
Output:
Output : NaN
Supported Browsers: The browsers supported by JavaScript Math.min( ) function are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- Introduction to JavaScript Course | Learn how to Build a task tracker using JavaScript
- JavaScript Course | Understanding Code Structure in JavaScript
- JavaScript Course | Logical Operators in JavaScript
- JavaScript Course | Conditional Operator in JavaScript
- JavaScript Course | Data Types in JavaScript
- JavaScript Course | Printing Hello World in JavaScript
- JavaScript Course | Loops in JavaScript
- JavaScript Course | Functions in JavaScript
- JavaScript Course | JavaScript Prompt Example
- JavaScript Course | Variables in JavaScript
- JavaScript Course | Objects in JavaScript
- JavaScript Course | Operators in JavaScript
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- How to include a JavaScript file in another JavaScript file ?
- this in JavaScript
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



