🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript | MDN
The Math.max() static method returns the largest of the numbers given as input parameters, or -Infinity if there are no parameters.
🌐
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
The Math.max() method returns the number with the highest value.
Discussions

Using Math.max to find number
function nextId(ids){ let max = Math.max(ids.join()); console.log(max) } nextId([0,1,2,3,5]); nextId([0,1,2,3,4,5,6,7,8,9,10]); nextId([1,2,0,2,3,5]); ``` Hello:) Can someone tell me pls, why as a result I get NaN More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
October 2, 2025
How do Javascript Math.max and Math.min actually work? - Stack Overflow
I am really curious how these functions actually work? I know there are a lot of questions about how to use these, I already know how to use them, but I couldn't find anywhere how to actually go ab... More on stackoverflow.com
🌐 stackoverflow.com
javascript - How do i use Math.max with an array of objects? - Stack Overflow
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max As, 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. More on stackoverflow.com
🌐 stackoverflow.com
JavaScript Math.max() Explained with Examples
Math Max Math.max() is a function that returns the largest value from a list of numeric values passed as parameters. If a non-numeric value is passed as a parameter, Math.max() will return NaN . An array of numeric values can be passed as a single parameter to Math.max() using either spread ... More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
8
September 8, 2019
🌐
The Ankler
theankler.com › p › three-budget-buckets-running-tv-shows-now-pitt-heated-rivalry
The Three Budget Buckets Running TV in 2026
3 weeks ago - This is the new math of television: It’s not just about whether your show works — it’s about where it lands on the cost spectrum.
🌐
Math.js
mathjs.org › docs › reference › functions › max.html
math.js | an extensive math library for JavaScript and Node.js
math.max(2, 1, 4, 3) // returns 4 math.max([2, 1, 4, 3]) // returns 4 // maximum over a specified dimension (zero-based) math.max([[2, 5], [4, 3], [1, 7]], 0) // returns [4, 7] math.max([[2, 5], [4, 3], [1, 7]], 1) // returns [5, 4, 7] 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
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Number › MAX_VALUE
Number.MAX_VALUE - JavaScript | MDN
October 22, 2025 - The Number.MAX_VALUE static data property represents the maximum numeric value representable in JavaScript.
🌐
freeCodeCamp
forum.freecodecamp.org › javascript
Using Math.max to find number - JavaScript - The freeCodeCamp Forum
October 2, 2025 - function nextId(ids){ let max = Math.max(ids.join()); console.log(max) } nextId([0,1,2,3,5]); nextId([0,1,2,3,4,5,6,7,8,9,10]); nextId([1,2,0,2,3,5]); ``` Hello:) Can someone tell me pls, why as a result I get Na…
Find elsewhere
🌐
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.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-math-max-method
JavaScript Math max() Method - GeeksforGeeks
September 30, 2024 - The Math.max() method in JavaScript returns the largest value from a set of zero or more numbers.
🌐
MDN
mdn2.netlify.app › en-us › docs › web › javascript › reference › global_objects › math › max
Math.max() - JavaScript | MDN
March 27, 2022 - The Math.max() function returns the largest of the zero or more numbers given as input parameters, or NaN if any parameter isn't a number and can't be converted into one.
🌐
Anthropic
anthropic.com › news › claude-sonnet-4-5
Introducing Claude Sonnet 4.5
We've added a new context editing feature and memory tool to the Claude API that lets agents run even longer and handle even greater complexity. In the Claude apps, we've brought code execution and file creation (spreadsheets, slides, and documents) directly into the conversation. And we've made the Claude for Chrome extension available to Max users who joined the waitlist last month.
🌐
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript
The Math.max() function returns the largest of the zero or more numbers given as input parameters.
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

🌐
freeCodeCamp
forum.freecodecamp.org › guide
JavaScript Math.max() Explained with Examples
September 8, 2019 - Math Max Math.max() is a function that returns the largest value from a list of numeric values passed as parameters. If a non-numeric value is passed as a parameter, Math.max() will return NaN .
🌐
Hacker News
news.ycombinator.com › item
Show HN: PureBee – A software-defined GPU running Llama 3.2 1B at 3.6 tok/SEC | Hacker News
3 weeks ago - PureBee is a complete GPU defined as a software specification — Memory, Engine, Instruction Set, Runtime. It runs Llama 3.2 1B inference at 3.6 tok/sec on a single CPU core. The model answers questions correctly · What makes it different from llama.cpp or WebLLM:
🌐
Medium
medium.com › @aniksarkar0177 › what-is-math-max-in-javascript-0999bf68923d
What is Math.max in JavaScript? - Aniksarkar - Medium
October 4, 2023 - In JavaScript, Math.max() is a built-in Math object function used to find the largest value among a set of numbers or elements. You can…
🌐
Droidscript
droidscript.org › javascript › Global_Objects › Math › max.html
Math.max
The Math.max() function returns the largest of zero or more numbers.