JavaScript min() method
Example
Return the smallest value:
Math.min(5,10);
Output result:
5
Try it »
Definition and Usage
The min() method returns the number with the smallest value among the specified numbers.
Browser support





All major browsers support the min() method
Syntax
Math.min(
n1
,
n2
,
n3
,...,nX)
Parameter value
| Parameters | Description |
|---|---|
| n1,n2,n3,...,nX | Optional. One or more values. Before ECMASCript v3, this method had only two parameters. |
Return Value
| Type | Description |
|---|---|
| Number | The smallest value among the parameters. If there are no parameters, Infinity is returned. If any parameter is NaN, or a non-numeric value that cannot be converted to a number, NaN is returned. |
Technical Details
| JavaScript version: | 1.0 |
|---|
Example
Example
Return the minimum value:
var a=Math.min(5,10);
var b=Math.min(0,150,30,20,38);
var c=Math.min(-5,10);
var d=Math.min(-5,-10);
var e=Math.min(1.5,2.5);
a,b,c,d, and LinkedHashMap, among others. e Output result:
5
0
-5
-10
1.5
Try it »
JavaScript Math object