Javascript - Math min() Method

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

Description

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

Syntax

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

Parameter Values

Parameter Require Description
n1, n2, n3, ..., nX Optional. One or more numbers to compare

Return

A Number, representing the lowest number of the arguments

Infinity if no arguments are given

NaN if one or more arguments are not numbers

Example

Return the number with the lowest value:

Demo

//return the lowest number of 5 and 10.
console.log(Math.min(5, 10));//from  w  w  w. j a  va 2  s  .  c  o m

//Return the number with the lowest value:
//compare numbers and return the lowest.
var a = Math.min(5, 10);
var b = Math.min(10, 150, 30, 20, 38);
var c = Math.min(-15, 10);
var d = Math.min(-15, -10);
var e = Math.min(1.15, 2.5);

var x = a + "\n" + b + "\n" + c + "\n" + d + "\n" + e;
console.log(x);

Result