JavaScript min() method

Definition and usage

min() The method returns the number with the smallest value.

Tip:max() The method returns the number with the highest value.

Example

Example 1

The smallest number returned:

Math.min(5, 10);

Try it yourself

Example 2

The smallest number returned:

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);

Try it yourself

Syntax

Math.min(n1, n2, n3, ... , nX)

Parameter value

Parameter Description
n1, n2, n3, ... , nX Optional. One or more numbers to be compared.

Technical details

Return value:

A number, representing the minimum value in the argument.

  • If no arguments are provided, it returns Infinity.
  • If one or more of the parameters are not numbers, it returns NaN.
JavaScript Version: ECMAScript 1

Browser Support

Method Chrome IE Firefox Safari Opera
min() Support Support Support Support Support

Related Pages

Tutorial:JavaScript Mathematics