CKTIS / JavaScript
Math.min: smallest value
Math.min converts every argument to Number and returns the smallest resulting value.
Version: ECMAScript 1 onward; example target: Node.js 24.22.2
Syntax
Math.min(...args)Math.min(...args) first applies ToNumber to every argument in order, then selects the smallest result. With no arguments it returns Infinity, the identity for finding a minimum. If any converted argument is NaN, the result is NaN; importantly, all conversions occur before that test.
Numeric strings and other convertible values are accepted, while a Symbol or BigInt throws TypeError. Objects can run valueOf or toString, and a conversion error stops the call. When the candidates are the two zeros, -0 is considered smaller than +0; -Infinity is smaller than every finite Number.
The function has existed since ECMAScript 1 and is not a constructor. For a small array, Math.min(...values) is practical. Do not spread a very large collection because argument limits are engine-dependent; use a loop or reduce and deliberately define empty-input and NaN handling.
Examples
const scores = [-4, 12, 7];
console.log(Math.min(...scores));
console.log(Math.min(), Number.isNaN(Math.min(3, undefined)));
console.log(Object.is(Math.min(-0, +0), -0));
console.log(Math.min("6", 2));
try { Math.min(1n, 2); } catch (error) { console.log(error instanceof TypeError); }
const seen = [];
const a = { valueOf() { seen.push("a"); return NaN; } };
const b = { valueOf() { seen.push("b"); return 4; } };
console.log(Number.isNaN(Math.min(a, b)), seen.join(","));Result
-4 Infinity true true 2 true true a,b
Math.min → -4 and ordered coercion a,b