JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Math Right Arrow min()

min()  Math  class method

Description

Returns the smallest of some numbers.

  • Like all class methods min() should be used on the class rather than an instance of the class.

Syntax


Signature Description
Math.min( [value1 [,value2[,...valueN]]])Returns the smallest of some numbers.

Parameters


Parameter Description
value1, value2, ...valueNThe values you wish to find the smallest number of:
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 0.

Examples

The code below displays min() usage.


// Store results in an array.
var minValues = new Array(6);
minValues[0] = Math.min(1.9, 1.6, 1.90001);
minValues[1] = Math.min(-10.8, -10.6, -10.59);
minValues[2] = Math.min('100.1', '100.2', '101');
minValues[3] = Math.min('five', 6, 7);
minValues[4] = Math.min();
minValues[5] = Math.min(null, null);
alert(minValues);  

Press the button below to action the above code:

Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math



  

go to home page Homepage go to top of page Top