min

Returns the smaller of two numbers.

Applies to

Math

Syntax

min(x,y)

Parameters

x,y

Numbers.

Description

min is a static method of Math. As a result, you always use it as Math.min(), rather than as a method of a Math object you create.

Examples

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.

See also

Math.max