Core JavaScript 1.5 Reference:Global Objects:Math:min
From MDC
(Redirected from Core JavaScript 1.5 Reference:Objects:Math:min)
Contents |
[edit] Summary
Returns the smallest of zero or more numbers.
| Method of Math | |
|
Static |
|
| Implemented in: | JavaScript 1.0, NES 2.0 |
| ECMA Version: | ECMA-262 |
[edit] Syntax
Math.min([value1[,value2[, ...]]])
[edit] Parameters
-
value1, value2, ... - Numbers.
[edit] Description
Because min is a static method of Math, you always use it as Math.min(), rather than as a method of a Math object you created.
If no arguments are given, the result is Infinity.
If at least one of arguments cannot be converted to a number, the result is NaN.
[edit] Examples
[edit] Example: Using Math.min
The following function evaluates the variables x and y:
function getMin(x,y) {
return Math.min(x,y)
}
If you pass getMin the values 10 and 20, it returns 10; if you pass it the values -10 and -20, it returns -20.