๐ŸŒ
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

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
How to use math.max with array
I've found Mozilla Developer Network (MDN) to be a great resource for JavaScript documentation. In this particular case, the last of the three examples they give right at the top of the page for Math.max() is exactly what you're looking for. As a PSA, when looking for JS tips, skip w3schools entirely. You're welcome. More on reddit.com
๐ŸŒ r/Bitburner
11
7
October 24, 2021
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
๐ŸŒ
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โ€ฆ
๐ŸŒ
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 โ€บ 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.
Find elsewhere
๐ŸŒ
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.
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

๐ŸŒ
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.
๐ŸŒ
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
2 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โ€ฆ