JavaScript Math.min() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

Math.min(...values) returns the smallest of the numbers you give it. Pass any number of values, such as Math.min(3, 9, 5), which returns 3.

Math is built into JavaScript. Call the method directly. It is not a constructor, so never write new Math().

Syntax

Call Math.min() like this. Start with this line.

JavaScript
Math.min(value1, value2, /* …, */ valueN)
CallWhat it does
Math.min(value1, value2, ...)Returns the smallest of the given numbers.
Math.min()With no arguments, returns Infinity.

Built into JavaScript. Call Math.min() on the Math object — no import required.

Library declarations
JavaScript
Math.min(value1, value2, /* …, */ valueN)
JavaScript
interface Math {
  min(...values: number[]): number;
}

Parameters

ParameterDescription
value1, ..., valueNOptional. Zero or more numbers to compare. Other values are converted to numbers.

Return Value

Return ValueDescription
numberThe smallest value. Returns Infinity if there are no arguments, and NaN if any argument is NaN or cannot be turned into a number.

JavaScript Examples

Example 1 — Basic Use

Pass numbers one by one. You get the smallest.

JavaScript
console.log(Math.min(3, 9, 5));     // 3
console.log(Math.min(-1, -5));      // -5
console.log(Math.min(2, "7"));      // 2
console.log(Math.min());            // Infinity
Try It Yourself

How It Works

  1. Pick the smallest. 3 is smaller than 9 and 5.
  2. Negatives. -5 is smaller than -1.
  3. Text numbers. "7" is converted to the number 7, so 2 still wins.
  4. No values. Math.min() returns Infinity.

Example 2 — Smallest Number in an Array

Use the spread operator ... to pass array items as arguments.

JavaScript
var prices = [19.99, 5.5, 12, 8.25];

console.log(Math.min(...prices));           // 5.5
console.log(Math.min.apply(null, prices));  // 5.5

var cheapest = prices.indexOf(Math.min(...prices));
console.log(cheapest);                      // 1
Try It Yourself

How It Works

  1. Spread. ...prices turns the array into separate values.
  2. apply. Math.min.apply(null, prices) is the older way and gives the same answer.
  3. Find the position. indexOf of the min tells you which item is cheapest.

Example 3 — Cap a Value and Watch for NaN

Use Math.min() to stop a value from going above a limit.

JavaScript
var price = 400;
var discount = Math.min(price * 0.2, 50);
console.log(discount);              // 50

var small = 100;
console.log(Math.min(small * 0.2, 50));  // 20

console.log(Math.min(20, NaN));     // NaN
console.log(Math.min(5, null));     // 0
Try It Yourself

How It Works

  1. Cap. 400 * 0.2 is 80, but the cap is 50, so you get 50.
  2. Under the cap. For 100, the discount is 20, which is below the cap.
  3. NaN trap. One NaN makes the whole result NaN.
  4. null trap. null becomes 0, which is the smallest.

Browser & Runtime Support

Math.min() has been part of JavaScript since ES1 and is Baseline Widely available everywhere.

✓ Baseline · ES1

Math.min()

Supported in every browser and Node.js version. No polyfill is needed.

99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support
Math.min Excellent

Bottom line: Use Math.min() freely. It works in all browsers and runtimes.

Frequently Asked Questions

Math.min(a, b, c) returns the smallest number from its arguments. Math.min(3, 9, 5) is 3.
Use the spread operator: Math.min(...numbers). The older way is Math.min.apply(null, numbers).
It returns Infinity. This is because every number is smaller than Infinity.
The result is NaN. Remove or fix bad values before you call Math.min().
Use Math.min(value, limit). For example, Math.min(250, 100) is 100, so the value never goes above 100.
Yes. Math.min(5, null) is 0 because null is converted to 0. Filter out null first if you do not want that.

Next: pow()

Learn how to raise a number to a power.

pow() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful