Home » JavaScript Tutorial

Math.min() Method with Example in JavaScript

JavaScript | Math.min() Method: Here, we are going to learn about the min() method of Math class in JavaScript with Examples.
Submitted by Shivang Yadav, on February 04, 2020

JavaScript | Math.min() Method

Math.min() is a function in math library of JavaScript that is used to return the smallest value of all the passed values to the method.

Syntax:

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

Parameter(s):

  • value1, value2, value3, ... – represent the values from which the smallest value is to returned.

Return value:

The return type of this method is number, it returns the smallest value of the passed parameters.

Values accepted: Integer, floating-point, numeric string.

Invalid Values: non-numeric string, empty variable, empty array all will return NaN (Not a Number).

Browser support: Chrome, Internet asinlorer, Mozilla, Safari, Opera mini.

Example 1: Valid values

console.log(Math.min(-1, 4, 6, 12));
console.log(Math.min(3.14, 43, 1, 0.2));
console.log(Math.min(0, -13, 4, 654));
console.log(Math.min("0.65", "-23"));

Output

-1
0.2
-13
-23

Example 2: Invalid values

console.log(Math.min("Javascript", "Hello"));

Output

NaN





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.