JavaScript Math.min() returns the smallest number from the values you pass to it. Searches like math min, js math min, javascript math min, math.min javascript, and javascript min all point to this method.
Tested On: The examples were tested with Node.js v20.18.1 on a Linux system. The same
Math.min()behavior works in modern browsers and JavaScript runtimes.
Math.min Syntax
Math.min(value1, value2, ...valueN)It returns the smallest numeric value. If any argument becomes NaN, the result is NaN.
Method 1: Find Minimum of Two Numbers
console.log(Math.min(10, 25));Output:
10Method 2: Find Minimum of Multiple Numbers
console.log(Math.min(12, 3, 4, 5, 67, 321, 121212));Output:
3Method 3: Find Minimum Value in an Array
Use spread syntax to pass array values as separate arguments.
const numbers = [3, 9, 2, 14];
console.log(Math.min(...numbers));Output:
2Method 4: Handle Empty Input and NaN
Calling Math.min() with no arguments returns Infinity.
console.log(Math.min());Output:
InfinityIf any argument is NaN, the result is NaN.
console.log(Math.min(1, NaN, 3));Output:
NaNCommon Questions About Math.min
How do I find the minimum number in JavaScript?
Use Math.min(a, b, c) for direct values, or Math.min(...array) for an array.
Why does Math.min return Infinity?
Math.min() returns Infinity when called with no arguments.
Does Math.min work with arrays directly?
No. Use Math.min(...numbers), not Math.min(numbers).
Summary
JavaScript Math.min() returns the smallest number from its arguments. Use it for direct numeric values or with spread syntax for arrays. No arguments return Infinity, and any NaN argument makes the result NaN.
