🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › min
Math.min() - JavaScript | MDN
July 20, 2025 - The Math.min() static method returns the smallest of the numbers given as input parameters, or Infinity if there are no parameters.
🌐
sebhastian
sebhastian.com › math-min-javascript
Find the lowest number with JavaScript's Math.min | sebhastian
January 5, 2021 - You can use JavaScript’s Math.min() method in order to find the number with the lowest value from several numbers.
🌐
Code.mu
code.mu › en › javascript › manual › math › Math.min
The Math.min method - a minimum number in JavaScript
The Math.min method returns the smallest number from the group of numbers passed as parameters in JavaScript.
🌐
W3Schools
w3schools.com › jsref › jsref_min.asp
W3Schools.com
The Math.min() method returns the number with the lowest value.
🌐
Quora
quora.com › What-is-the-time-complexity-for-JavaScript-Math-min
What is the time complexity for JavaScript Math.min()? - Quora
Math.min() runs in O(n) time when given n numeric arguments (including elements if called with apply/spread).
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Scripting › Math
Basic math in JavaScript — numbers and operators - Learn web development | MDN
At this point in the course, we discuss math in JavaScript — how we can use operators and other features to successfully manipulate numbers to do our bidding.
🌐
MathJax
mathjax.org
MathJax
Support for LaTeX, MathML, and other equation markup directly in the HTML source. An extensible, modular design with a rich API for easy integration into web and node.js applications.
🌐
Math.js
mathjs.org › docs › reference › functions › min.html
math.js
math.min(2, 1, 4, 3) // returns 1 math.min([2, 1, 4, 3]) // returns 1 // minimum over a specified dimension (zero-based) math.min([[2, 5], [4, 3], [1, 7]], 0) // returns [1, 3] math.min([[2, 5], [4, 3], [1, 7]], 1) // returns [2, 3, 1] math.max(2.7, 7.1, -4.5, 2.0, 4.1) // returns 7.1 math.min(2.7, 7.1, -4.5, 2.0, 4.1) // returns -4.5 ·
Find elsewhere
🌐
Scaler
scaler.com › home › topics › math min() javascript function
Math min() JavaScript Function - Scaler Topics
May 4, 2023 - The Math.min() function returns the smallest value of all the passed values. In case no value is passed to the function it will return positive infinity as it compares the first value with positive infinity and in absence of a first value, the ...
🌐
Medium
allaboutcode.medium.com › finding-the-min-max-value-in-an-array-in-javascript-3bcea14960d1
Finding the Min/Max Value in an Array in JavaScript | by Marika Lam | Medium
June 26, 2024 - 1 min read · ·Jun 26, 2024 · -- Share · The Math object’s Math.min() and Math.max() methods are static methods that return the minimum and maximum elements of a given array.
🌐
Coderslang
learn.coderslang.com › js-test-12
JS Interview #12: Math.min()
November 30, 2020 - The function Math.min() takes the variable number of arguments and returns the lowest number passed into it.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript | MDN
js · const arr = [1, 2, 3]; const max = Math.max(...arr); However, both spread (...) and apply will either fail or return the wrong result if the array has too many elements, because they try to pass the array elements as function parameters. See Using apply and built-in functions for more details. The reduce solution does not have this problem. Math.min() Was this page helpful to you?
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MIN_SAFE_INTEGER
Number.MIN_SAFE_INTEGER - JavaScript | MDN
October 22, 2025 - The Number.MIN_SAFE_INTEGER static data property represents the minimum safe integer in JavaScript, or -(253 - 1).
🌐
DEV Community
dev.to › coderslang › js-test-12-math-min-50an
JS Test #12: Math.min() - DEV Community
February 16, 2021 - The function Math.min() takes the variable number of arguments and returns the lowest number passed into it.
Top answer
1 of 7
15

Here is the Math.max code in Chrome V8 engine.

function MathMax(arg1, arg2) {  // length == 2
  var length = %_ArgumentsLength();
  if (length == 2) {
    arg1 = TO_NUMBER(arg1);
    arg2 = TO_NUMBER(arg2);
    if (arg2 > arg1) return arg2;
    if (arg1 > arg2) return arg1;
    if (arg1 == arg2) {
      // Make sure -0 is considered less than +0.
      return (arg1 === 0 && %_IsMinusZero(arg1)) ? arg2 : arg1;
    }
    // All comparisons failed, one of the arguments must be NaN.
    return NaN;
  }
  var r = -INFINITY;
  for (var i = 0; i < length; i++) {
    var n = %_Arguments(i);
    n = TO_NUMBER(n);
    // Make sure +0 is considered greater than -0.
    if (NUMBER_IS_NAN(n) || n > r || (r === 0 && n === 0 && %_IsMinusZero(r))) {
      r = n;
    }
  }
  return r;
}

Here is the repository.

2 of 7
7

Below is how to implement the functions if Math.min() and Math.max() did not exist.

Functions have an arguments object, which you can iterate through to get its values.

It's important to note that Math.min() with no arguments returns Infinity, and Math.max() with no arguments returns -Infinity.

function min() {
  var result= Infinity;
  for(var i in arguments) {
    if(arguments[i] < result) {
      result = arguments[i];
    }
  }
  return result;
}

function max() {
  var result= -Infinity;
  for(var i in arguments) {
    if(arguments[i] > result) {
      result = arguments[i];
    }
  }
  return result;
}

//Tests
console.log(min(5,3,-2,4,14));       //-2
console.log(Math.min(5,3,-2,4,14));  //-2

console.log(max(5,3,-2,4,14));       //14
console.log(Math.max(5,3,-2,4,14));  //14

console.log(min());                  //Infinity
console.log(Math.min());             //Infinity

console.log(max());                  //-Infinity
console.log(Math.max());             //-Infinity

🌐
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › Math › min
Math.min() - JavaScript
The static function Math.min() returns the lowest-valued number passed into it, or NaN if any parameter isn't a number and can't be converted into one.
🌐
Learnjavascript
learnjavascript.co.uk › reference › globals › math › min.html
JavaScript Math min() Method
// Store results in an array. var minValues = new Array(6); minValues[0] = Math.min(1.9, 1.6, 1.90001); minValues[1] = Math.min(-10.8, -10.6, -10.59); minValues[2] = Math.min('100.1', '100.2', '101'); minValues[3] = Math.min('five', 6, 7); minValues[4] = Math.min(); minValues[5] = Math.min(null, null); alert(minValues); JavaScript Advanced Tutorials - Lesson 4 - Math ·