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()}`);
Run code snippetEdit code snippet Hide Results Copy to answer Expand

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 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
February 15, 2022
[Javascript] In array of objects, find max value of a specific property (weight of guy), but then return a different property (guy's name) of that object with that max?

Are you okay with sorting the array?

Dudes = Dudes.sort(function(a, b){
return a.weight < b.weight;
});
console.log(Dudes[0].fName);
More on reddit.com
🌐 r/learnprogramming
8
0
October 12, 2017
How do I set minimum and maximum elements for an array?
I don't think there is an ellegant way to do so, I guess you can do it by defining each tuple you want to support. type coords = [LatLng, LatLng] | [LatLng, LatLng, LatLng] | [LatLng, LatLng, LatLng, LatLng] .... More on reddit.com
🌐 r/typescript
8
5
September 14, 2020
Unnest an Array
Im working on GCP Billing queries in BQ. But while extracting array with the cost I'm getting wrong values like unnest returns array elements in row… More on reddit.com
🌐 r/bigquery
1
3
November 19, 2018
🌐
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 › 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
🌐
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
The Math.max() method returns the number with the highest value.
🌐
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.
Find elsewhere
🌐
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.
🌐
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 - We can use this method to sort ... console.log(max); // Output: 9 · The Math.max() function is a built-in JavaScript function that takes any number of arguments and returns the maximum value....
🌐
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
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-max-element-in-an-array
JavaScript - Max Element in an Array - GeeksforGeeks
July 23, 2025 - The forEach method iterates over each element in the array, comparing each element to a variable (max) initialized to the first element. If the current element is greater than max, max is updated. After the loop, max holds the largest value.
🌐
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 ·
🌐
Sabe
sabe.io › blog › javascript-index-max-value-array
Get the Index of the Max Value of an Array in JavaScript | Sabe
August 22, 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<!-- --> | megafauna.dev 🦣
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 Using JavaScript
In our case we are using it for comparison since if you compare any value to ∞, the ∞ will always be higher than that number. In the case of the maximum value, we will set it to minus Infinity (-∞) because no number is less than -∞.
🌐
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 - <html> <body> <p>Original array: [28, 45, 69, 20, 15, 7, 98]</p> <p id="result1"></p> <script> let array = [28, 45, 69, 20, 15, 7, 98]; let min = array[0]; let max = array[0]; for (let i = 1; i < array.length; i++) { if (array[i] > max) { max = array[i]; } if (array[i] < min) { min = array[i]; } } document.getElementById('result1').innerHTML = "Maximum element: " + max + "<br>" + "Minimum element: " + min; </script> </body> </html> ... JavaScript provides built-in Math.min() and Math.max() methods that accept multiple arguments and return the minimum and maximum values respectively.
🌐
W3Schools
w3schools.com › js › js_array_sort.asp
JavaScript Array Sort
There is no built-in function for finding the highest value in a JavaScript array. The fastest code to find the highest number is to use a home made method. This function loops through an array comparing each value with the highest value found: ...
🌐
Medium
medium.com › @vladbezden › how-to-get-min-or-max-of-an-array-in-javascript-1c264ec6e1aa
How to get min or max of an array in JavaScript | by Vlad Bezden | Medium
September 2, 2016 - How to get min or max of an array in JavaScript max function of Math object The Math.max() function returns the largest of zero or more numbers. and min function of Math object The Math.min() …