Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Function

Math.min

Math.min() returns the smallest of zero or more supplied values. It returns Infinity with no arguments and NaN if any argument is or converts to NaN.

How it works

Math.min() compares all supplied arguments after converting them to numbers and returns the lowest result. With no arguments it returns Infinity; if any argument becomes NaN, the overall result is NaN. It is a static Math method, so call it as Math.min().

Syntax

Math.min(value1)
Math.min(value1, value2)
Math.min(value1, value2, /* …, */ valueN)

Parameters

NameTypeDescription
value1, …, valueNnumberZero or more numbers among which the lowest value will be selected and returned.

Returns

The smallest of the given numbers; Infinity with no arguments, or NaN if any argument is or converts to NaN.

Key points

  • It selects and returns the lowest value among its arguments.
  • Calling it without arguments produces positive Infinity.
  • The function supports an empty argument list as well as multiple numeric inputs.
  • Its length property is 2, although the function also accepts zero or one argument.
  • The returned minimum can be assigned directly to another variable.
  • Use it to enforce an upper bound, such as limiting a computed value to a maximum.

Common mistakes

  • Any argument that is NaN, or converts to NaN, makes the result NaN.
  • Do not call it as an instance method on a Math-like object.

Example: Find a minimum and clip a value

const values = [2, 3, 1];
const smallest = Math.min(...values);
const clipped = Math.min(100, 137);

console.log(smallest); // 1
console.log(clipped); // 100

The spread syntax supplies the array elements as arguments; the second call limits the value to a maximum of 100.

When to use it

Minimum selection

Choose the lowest value from several numeric candidates.

Upper-bound clipping

Keep a computed value from exceeding a maximum.

Array minimum

Reduce an array to its smallest numeric element using spread syntax.

Interview questions

QWhat does Math.min() return for empty input and invalid numeric input?

Math.min() returns the smallest supplied number. With zero arguments, it returns Infinity; if any argument is or converts to NaN, it returns NaN.

Follow-up: What happens with an array argument? Math.min(array) does not compare its elements; use Math.min(...array), while keeping argument-list limits in mind.

QHow are Math.min() arguments treated?

The function accepts zero or more values and selects the lowest numeric value. Values are converted to numbers as part of the operation, so conversions that produce NaN contaminate the result.

Follow-up: How would you safely handle untrusted values? Validate or explicitly convert them before calling Math.min(), then reject NaN rather than treating it as a valid bound.

QWhy is Math.min() called through Math?

Math.min() is static and belongs to the Math namespace, which is not a constructor. Invoke it as Math.min(...), not through an object created with new Math().

Follow-up: How can you find the minimum of an array? Spread the array into Math.min(...array), or use a loop for arbitrarily large input to avoid argument-length limits.

  • Math.max()
  • Math.ceil()
  • Math.floor()
  • Math.round()
  • Number.NaN

Source: Math.min() - JavaScript | MDN Web Docs. Checked 2026-10-15.