A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-math-min-method/ below:

JavaScript Math min() Method - GeeksforGeeks

JavaScript Math min() Method

Last Updated : 15 Jul, 2024

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:

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));

Example 3: When no parameters are passed.

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

Output:

Result : Infinity

Example 4: 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

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.



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4