W3Schools.com

JavaScript min() Method

Math Object Reference JavaScript Math Object

Definition and Usage

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

Syntax

Math.min(x,y,z,...,n)

Parameter Description
x,y,z,...,n Optional. One or more numbers.
If no arguments are given, the result is Infinity


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The min() method is supported in all major browsers.


Example

Example

Return the number with the lowest value:

<script type="text/javascript">

document.write(Math.min(5,10) + "<br />");
document.write(Math.min(0,150,30,20,38) + "<br />");
document.write(Math.min(-5,10) + "<br />");
document.write(Math.min(-5,-10) + "<br />");
document.write(Math.min(1.5,2.5));

</script>

The output of the code above will be:

5
0
-5
-10
1.5

Try it yourself »


Math Object Reference JavaScript Math Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
XML Editor - Free Trial!
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE