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 Web Docs
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
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
Negative Indexes in JavaScript Arrays
Frustratingly, Array.prototype.slice already handles negative indices as you'd expect: > [1, 2, 3, 4].slice(-1) < [4] > [1, 2, 3, 4].slice(-2) < [3, 4] > [1, 2, 3, 4].slice(-2, -1) < [3] Which incidentally means that if you're using ES6 features you can combine this and unpacking for "negative indexing": > var [a] = [1, 2, 3, 4].slice(-1) > a < 4 More on reddit.com
🌐 r/programming
9
3
October 9, 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
🌐
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.
🌐
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 - If you dig into Math.max you will find out that it can take a list of numbers or an array of numbers. This means that all you have to do is get an array of id's and you can pass that into the max() function. If you were paying attention you ...
🌐
Built In
builtin.com › articles › javascript-array-max
3 Ways to Find the Maximum Value in a JavaScript Array
February 16, 2024 - 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.
🌐
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 ... => { return b - a; }); const max = arr[0]; 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 ...
Find elsewhere
🌐
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().
🌐
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
cssText getPropertyPriority() ... let d = Math.max(-5, -10); let e = Math.max(1.5, 2.5); Try it Yourself » · The Math.max() method returns the number with the highest 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 - a[0].value: After sorting, the first object (a[0]) will have the highest value, so it's assigned to max. The forEach approach iterates through the array of objects, checking each object's attribute value. It keeps track of the highest value found. JavaScript · const getMax = (a, att) => { let max = -Infinity; a.forEach(obj => { if (obj[att] > max) { max = obj[att]; } }); return max; }; const a = [{x: 1}, {x: 2}, {x: 3}]; const maxVal = getMax(a, 'x'); console.log(maxVal); Output ·
🌐
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 - That is because Math.min or Math.max functions expect distinct variables and not an array. So in order to do that before ES6/ES2015 apply method was used · var nums = [1, 2, 3] Math.min.apply(Math, nums) // 1 Math.max.apply(Math, nums) // 3 Math.min.apply(null, nums) // 1 Math.max.apply(null, nums) // 3 · With ES6/ES2016 destructuring assignment it becomes easier · The destructuring assignment syntax is a JavaScript expression that makes it possible to extract data from arrays or objects into distinct variables.
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Math › max
JavaScript Math max() - Find Maximum Value | Vultr Docs
November 27, 2024 - The Math.max() method in JavaScript is a straightforward yet powerful tool used to determine the maximum value among its given arguments. By accepting multiple numbers or an array of numbers (with a spread operator), this method evaluates and ...
🌐
W3docs
w3docs.com › javascript
How to Find the Min/Max Elements in an Array in JavaScript
let arrayList = [1, 2, 3, 4, 3, 21, 0]; let max = arrayList[0]; for (let i = 1; i < arrayList.length; ++i) { if (arrayList[i] > max) { max = arrayList[i]; } } console.log(max); ... testArr.reduce(function (a, b) { return Math.max(a, b); }); ...
🌐
YouTube
youtube.com › code 2020
JavaScript tips — Find the maximum value in an array of numbers - YouTube
You can find the largest number in an array in #JavaScript with a single function call and without writing any loopsJust call Math.max(...yourArray) to get t...
Published   October 5, 2022
Views   4K
🌐
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.
🌐
W3Resource
w3resource.com › javascript-exercises › javascript-math-exercise-6.php
JavaScript Math: Find the highest value in an array - w3resource
Write a JavaScript function to find the highest value in an array. Test Data : console.log(max([12,34,56,1])); console.log(max([-12,-34,0,-56,-1])); 56 0
🌐
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.