The Wayback Machine - https://web.archive.org/web/20240119132715/https://www.geeksforgeeks.org/javascript-math-min-method/
Open In App
Related Articles

JavaScript Math min() Method

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The JavaScript Math min( ) Method is used to return the lowest-valued number passed in the method. The Math.min() method returns NaN if any parameter isn’t a number and can’t be converted into one. The min() is a static method of Math, therefore, it is always used as Math.min(), rather than as a method of a Math object created. 

Syntax:

Math.min(value1, value2, ...)

Parameters: This method accepts a single parameter that can be used n number of times as mentioned above and described below:

  • value: These values are sent to math.min() method for finding the largest.

Return Value: The Math.min() method returns the smallest of the given numbers.

Example 1: Below are examples of the Math min() Method.

javascript




console.log("When positive numbers are passed" +
    " as parameters: " + Math.min(10, 32, 2));


Output

When positive numbers are passed as parameters: 2

Example 2: When negative numbers are passed as parameters. 

javascript




console.log("Result : " + Math.min(-10, -32, -1));


Output

Result : -32

Example 3: When no parameters are passed.

javascript




console.log("Result : " + Math.min());


Output:

Result : Infinity

Program 3: When NaN is passed as a parameter.

javascript




console.log("Result : " + Math.min(10,2,NaN));


Output:

Result : NaN

We have a complete list of Javascript Math Objects methods, to check those please go through this Javascript Math Object Complete reference article.

Supported Browsers:

  • Google Chrome 1 and above
  • Firefox 1 and above
  • Opera 3 and above
  • Safari 1 and above

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.


Learn to code easily with our course Coding for Everyone. This course is accessible and designed for everyone, even if you're new to coding. Start today and join millions on a journey to improve your skills!

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 01 Aug, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials