How about augmenting the built-in Array object to use Math.max/Math.min instead:

Array.prototype.max = function() {
  return Math.max.apply(null, this);
};

Array.prototype.min = function() {
  return Math.min.apply(null, this);
};

let p = [35,2,65,7,8,9,12,121,33,99];

console.log(`Max value is: ${p.max()}` +
  `\nMin value is: ${p.min()}`);

Here is a JSFiddle.

Augmenting the built-ins can cause collisions with other libraries (some see), so you may be more comfortable with just apply'ing Math.xxx() to your array directly:

var min = Math.min.apply(null, arr),
    max = Math.max.apply(null, arr);

Alternately, assuming your browser supports ECMAScript 6, you can use spread syntax which functions similarly to the apply method:

var min = Math.min( ...arr ),
    max = Math.max( ...arr );
Answer from Roatin Marth on Stack Overflow
🌐
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. console.log(Math.max(1, 3, 2)); // Expected output: 3 console.log(Math.max(-1, -3, -2)); // Expected output: -1 const array = [1, 3, 2]; console.log(Math.max(...
Discussions

How can I easily obtain the min or max element of a JavaScript array? - TestMu AI Community
How can I easily obtain the min or max element of a JavaScript array · You can easily obtain the minimum and maximum elements of a JavaScript array using the Math.min() and Math.max() functions along with the spread operator. Here’s how you can do it: More on community.testmu.ai
🌐 community.testmu.ai
0
August 21, 2024
How to make function to find min max value of array?
var min = values[0];
var max = values[0];
for(var count = 1; count = values.length; count++)
{
    if(values[count] < min)
        min = values[count];
    if(values[count] > max)
        max = values[count];
}

I'm on mobile. I'll fix the formatting later.

More on reddit.com
🌐 r/learnjavascript
3
1
July 18, 2016
Map or Reduce to calculate max value from JSON
That SO solution is more elegant. It uses map to create a new array of just the values, then passes that to the built-in Math.max. Your solution is slightly more complicated and basically does just what Math.max does anyway. Edit: However, I knocked together a quick jsperf and it looks like the Math.max version is slower: http://jsperf.com/math-max-vs-ternery Personally I'd still go with Math.max as I find it easier to understand, and I really doubt there will be many situations in which this'd be a performance bottleneck. More on reddit.com
🌐 r/javascript
12
2
May 26, 2015
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 28, 2021
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › find-the-min-max-element-of-an-array-using-javascript
Min and Max of an Array in JavaScript - GeeksforGeeks
To find the minimum or maximum element in a JavaScript array, use Math.min or Math.max with the spread operator.
Published   August 2, 2025
🌐
Built In
builtin.com › articles › javascript-array-max
3 Methods to Find the JavaScript Array Max | Built In
Arrays are a versatile structure in JavaScript that holds multiple data types. Find the maximum value in an array using for loop, math.max() and the reduce method.
🌐
CoreUI
coreui.io › answers › how-to-find-the-maximum-value-in-an-array-in-javascript
How to find the maximum value in an array in JavaScript · CoreUI
September 21, 2025 - This approach is concise, readable, and leverages JavaScript’s built-in mathematical functions for optimal performance. Use Math.max() with the spread operator to find the largest value in an array.
🌐
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
The Math.max() method returns the number with the highest value. The Math.min() Method · Math.max(n1, n2,...) Full JavaScript Math Tutorial · Full JavaScript Math Reference · Full JavaScript Numbers Tutorial · Full JavaScript Number Reference ...
🌐
Seanconnolly
seanconnolly.dev › javascript-find-element-with-max-value
How to get the element with the max value in a JavaScript array · Sean Connolly
Array.find is a very useful function but only if you can determine whether or not you have the right item independently from other items in the array, e.g. finding the player named Leanne Graham: const leanne = players.find(p => p.name === "Leanne Graham"); Math.max could be used if you only cared about the value instead of the item that holds the value, e.g.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-max-element-in-an-array
JavaScript - Max Element in an Array - GeeksforGeeks
July 23, 2025 - The spread operator (...) allows an iterable such as an array to be expanded in places where zero or more arguments or elements are expected. This operator can be used with Math.max() to find the largest element in the array.
🌐
Medium
medium.com › @amitsharma_24072 › 3-efficient-ways-to-find-maximum-value-in-javascript-arrays-515463ebd17
3 Efficient Ways to Find Maximum Value in JavaScript Arrays | by Amit Sharma | Medium
July 11, 2024 - For loop will iterate over the array and compare each element to find the maximum value: const arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]; let max = arr[0]; for (let i = 1; i < arr.length; i++) { if (arr[i] > max) { max = arr[i]; } } console.log(max); // Output: 9 · The sort() method is a built-in JavaScript method that sorts the elements of an array.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › array › min and max value of an array
Min and max value of a JavaScript array - 30 seconds of code
December 30, 2023 - If n is greater than or equal to the length of the array, we'll get the original array back. const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); minN([1, 2, 3]); // [1] minN([1, 2, 3], 2); // [1, 2] maxN([1, 2, 3]); // [3] maxN([1, 2, 3], 2); // [3, 2] For more complex cases, such as finding the min/max value in an array of objects, you will have to use Array.prototype.map().
🌐
CodeBurst
codeburst.io › javascript-finding-minimum-and-maximum-values-in-an-array-of-objects-329c5c7e22a2
JavaScript: Finding Minimum and Maximum values in an Array of Objects | by Brandon Morelli | codeburst
August 21, 2017 - Now that we have a simple Array of numbers, we use Math.min() or Math.max() to return the min/max values from our new Y value array. The spread operator allows us to insert an array into the built in function. Note — If you’re interested in learning more about the spread operator, check out this article: JavaScript & The spread operator
🌐
Quora
quora.com › How-can-you-find-the-highest-and-lowest-in-an-array-of-objects-JavaScript-Javascript-arrays-object-average-development
How to find the highest and lowest in an array of objects/JavaScript (Javascript, arrays, object, average, development) - Quora
Answer (1 of 3): For this algorithm, I think the best runtime you can get is O(n) with n being the length of the array. Declare two variables to hold the highest and lowest numbers of the array and set their values to the first element of the array. Iterate through the array and check each elem...
🌐
danvega.dev
danvega.dev › blog › find-max-array-objects-javascript
How to find the max id in an array of objects in JavaScript
March 14, 2019 - Here you are going to call reduce on the characters array. You will define a accumulator which will accumulate the callback's return value. Every time the callback function is called it will return a value and store it in max. The callback method is looking at the character id and if it's greater than max it returns that, if not it returns max.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-search-the-max-value-of-an-attribute-in-an-array-object
How To Search The Max Value of an Attribute in an Array Object? - GeeksforGeeks
July 15, 2025 - If the price is greater than the current max, it updates the max with the new value. After the loop finishes, max holds the highest price value. We can find the max value of an attribute by using Math.max.apply() function. javascript ·
🌐
TestMu AI Community
community.testmu.ai › ask a question
How can I easily obtain the min or max element of a JavaScript array? - TestMu AI Community
August 21, 2024 - How can I easily obtain the min or max element of a JavaScript array · You can easily obtain the minimum and maximum elements of a JavaScript array using the Math.min() and Math.max() functions along with the spread operator.
🌐
Sabe
sabe.io › blog › javascript-index-max-value-array
Get the Index of the Max Value of an Array in JavaScript
August 21, 2022 - JAVASCRIPTconst array = [4, 25, 37, 54, 73, 83, 21, 42]; const highestValue = Math.max(...array); console.log(highestValue); ... Now that we have the highest value in the array, we just need to find the index of that value.
🌐
Megafauna
megafauna.dev › posts › max-value-array-javascript
Find the Max Value in a JavaScript Array
July 8, 2022 - However, as previously mentioned, using Array.reduce() in conjunction with Math.max() may be a better approach when working with large arrays. Internet Explorer doesn't support the spread syntax. The above example may not work depending on your application's build process & browser support requirements. Here's an approach for finding the max value in an array by using Math.max with .apply,
🌐
GitConnected
levelup.gitconnected.com › max-value-in-an-array-of-numbers-in-javascript-9aa56efdea04
Max Value in an Array of Numbers in JavaScript | by The Software Line | Level Up Coding
September 8, 2024 - It’s important to know that the pop() method also removes the last element from the sorted (temporary) array in this case. Original array is not changed because we sorted the new array (copy from the original one). ... Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev ... Computer Science degree. Full-Stack Software Engineer and Tech/Team Lead. Writing about Tech/Web Development (JavaScript, TypeScript, Angular).
🌐
AlgoDaily
algodaily.com › lessons › how-to-find-min-max-val-in-arr-using-js
AlgoDaily - Find Minimum And Maximum Value In An Array ...
Programming interview prep bootcamp with coding challenges and practice. Daily coding interview questions. Software interview prep made easy.
🌐
TutorialsPoint
tutorialspoint.com › how-to-find-the-min-max-element-of-an-array-in-javascript
How to find the min/max element of an Array in JavaScript?
October 31, 2022 - After performing these steps, we will use for loop to traverse the array elements and update the values of min and max with each iteration to the current minimum and the maximum element in the array. In this approach of finding the maximum and the minimum element in the array, we will use the in-built Math.max() and Math.min() methods of JavaScript with the apply() method or array destructuring syntax.