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.
Videos
00:56
JavaScript Math max() method - JavaScript Tutorial for Beginners ...
03:56
JavaScript tips — Find the maximum value in an array of numbers ...
05:23
How to Find Maximum and Minimum in an Array in JavaScript ...
01:00
JavaScript Methods | Math.min() and Math.max() - YouTube
08:09
Diving into JavaScript source code - Math.max() and Math.min ...
05:08
Find the Biggest Number with Math.max() in JavaScript | Important ...
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 .
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
The Math.max() method returns the number with the highest value.
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.
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
Reddit
reddit.com › r/bitburner › how to use math.max with array
r/Bitburner on Reddit: How to use math.max with array
October 28, 2021 -
I'm trying to get the maximum value in an array. What's the correct syntax to do this?
Alternative, is there a way to compare different variables and get the name of the variable with the highest value? Like
var memory = 10 var cores = 20 var level = 200 var node = 5 -> return "level"
Top answer 1 of 3
7
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.
2 of 3
3
You could use destructuring spread syntax: Math.max(...arr) That would pass all entries of the array as individual arguments to the function. Alternatively you could use "reduce", which would be a useful function to have in your toolbelt in general anyway. I don't remember the exact syntax rn, but I believe it looks something like: arr.reduce((a,b) => Math.max(a,b)) Someone will want to verify and/or correct me on this, and probably expand on it a bit.
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.
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.
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.
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
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:
Droidscript
droidscript.org › javascript › Global_Objects › Math › max.html
Math.max
The Math.max() function returns the largest of zero or more numbers.
Reading Eggs
readingeggs.com
Learning to Read for Kids | Learn to Read with Phonics | Free Trial – Reading Eggs
Reading Eggs is the online reading program that helps children learn to read. Hundreds of online reading lessons, phonics games and books for ages 2–13. Start your free trial!
EDUCBA
educba.com › home › software development › software development tutorials › javascript tutorial › javascript max
JavaScript Math max() Method [Function & Examples]
April 18, 2023 - Javascript max uses the Math.max to find out the maximum number among the list of the numeric values that are supplied to the function as its parameters. This method helps to retrieve the maximum numeric value.
Call +917738666252
Address Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai