To find the maximum y value of the objects in array:

Math.max.apply(Math, array.map(function(o) { return o.y; }))

or in more modern JavaScript:

Math.max(...array.map(o => o.y))

Warning:

This method is not advisable, it is better to use reduce. With a large array, Math.max will be called with a large number of arguments, which can cause stack overflow.

Answer from tobyodavies on Stack Overflow
🌐
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 ...
Discussions

ES6 Find the maximum number of an array of objects?

If you want to use ES6 and get this done in one line:

const shots = [
{id: 1, amount: 2},
{id: 2, amount: 4},
{id: 3, amount: 52},
{id: 4, amount: 36},
{id: 5, amount: 13},
{id: 6, amount: 33}
];

shots.reduce((acc, shot) => acc = acc > shot.amount ? acc : shot.amount, 0);

Can replace the ternary with a Math.max(acc, shot.amount), along with many other multiple methods. The issue with the reduce function you produced on SO, your reducer accumulator/initial value (0) was placed in the wrong spot.

More on reddit.com
🌐 r/javascript
3
0
February 14, 2018
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
[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 to check an Array of objects contains matching values with enum
try: resp.filter(z => x.some(y => z['name'] === y) I've slightly reduced the variable names to make it less confusing. Seriously, never do something like x or y. Its just hard to read and does not improve the code in any meaningful way. More on reddit.com
🌐 r/typescript
5
9
January 29, 2020
🌐
Seanconnolly
seanconnolly.dev › javascript-find-element-with-max-value
How to get the element with the max value in a JavaScript array · Sean Connolly
One notable trait of this array is that it is unsorted so we cannot simply grab the first element (or last, depending on sort direction). Instead we need an algorithm that compares the elements against each other and returns the element with the max wins value. The Array.reduce is our friend here. If you haven't seen the function signature before, it reads a bit awkwardly: arr.reduce(callback( accumulator, currentValue[, index[, array]] ) { // return result from executing something for accumulator or currentValue }[, initialValue]);
🌐
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 - javascript · let a = [ {a: 10, ... in an array of objects. It uses arr.map() to create a new array of a values, then Math.max.apply() to find the highest value from that array....
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript - MDN Web Docs
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(...array)); // Expected output: 3 ... Zero or more numbers among which the largest value will be selected and returned. The largest of the given numbers. Returns NaN if any of the parameters is or is converted into NaN. Returns -Infinity if no parameters are provided. Because max() is a static method of Math, you always use it as Math.max(), rather than as a method of a Math object you created (Math is not a constructor).
🌐
Medium
rathoreaparna678.medium.com › how-to-get-min-or-max-value-of-a-property-in-a-javascript-array-of-objects-b39c279205b9
How to Get Min or Max Value of a Property in a JavaScript Array of Objects? | by Aparna Rathore | Medium
July 17, 2023 - const maxScore = findMaxValue(data, ‘score’); console.log(maxScore); // Output: 95 ``` In both cases, the `reduce()` function is used to iterate over each object in the array. The initial value (`Infinity` for minimum, `-Infinity` for maximum) is set to ensure that the first comparison sets the initial minimum or maximum value correctly.
🌐
Jason Watmore's Blog
jasonwatmore.com › post › 2021 › 09 › 14 › vanilla-js-get-the-max-prop-value-from-an-object-array-in-javascript
Vanilla JS - Get the max prop value from an object array in JavaScript | Jason Watmore's Blog
September 14, 2021 - Run the example vanilla JS on StackBlitz at https://stackblitz.com/edit/vanilla-js-get-max-prop-value-from-object-array. For more info on the Vanilla JS functions and operator used in the example see the below links: Array map function - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-get-max-id-in-array-of-objects
Get the Max id in an Array of Objects in JavaScript | bobbyhadz
We used the spread syntax (...) ... the values from the array get passed as multiple, comma-separated arguments to the Math.max() method....
🌐
TutorialsPoint
tutorialspoint.com › 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 ?
July 18, 2023 - const max = array.reduce((prev, current) => (prev.attribute > current.attribute) ? prev : current); Here, the reduce() method allows us to iterate through an array and apply a reduction operation. In this case, we use reduce() to compare the attribute value of each object with the previous maximum value and return the object with the higher attribute value.
🌐
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 - For objects, use: Math.max(...array.map(item => item.value)). Angular · Bootstrap · React.js · Vue.js · Follow Łukasz Holeczek on GitHub Connect with Łukasz Holeczek on LinkedIn Follow Łukasz Holeczek on X (Twitter) Łukasz Holeczek, Founder of CoreUI, is a seasoned Fullstack Developer and entrepreneur with over 25 years of experience. As the lead developer for all JavaScript, React.js, and Vue.js products at CoreUI, they specialize in creating open-source solutions that empower developers to build better and more accessible user interfaces.
🌐
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.
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-get-min-or-max-value-of-a-property-in-a-javascript-array-of-objects-3fdf318f2019
How to Get Min or Max Value of a Property in a JavaScript Array of Objects? | by John Au-Yeung | JavaScript in Plain English
July 23, 2024 - We can get the min or max value of a property in objects in a JavaScript object array by calling map to create an array of the property values. Then we can use the Math.min or Math.max methods to get the min or max values from the array by spreading ...
🌐
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 ...
🌐
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.
🌐
Daily Dev Tips
daily-dev-tips.com › posts › javascript-find-min-max-from-array-of-objects
JavaScript find min/max from array of objects
July 17, 2022 - We are very explicit with the above examples by using the curly brackets and returning the object. However, seeing we only have one line, we can write it as the shorthand function like this. const highest = users.reduce((prev, cur) => (cur.age > prev.age ? cur : prev)); const lowest = users.reduce((prev, cur) => (cur.age < prev.age ? cur : prev)); Way shorter, right, but it takes some of the readability in one go. ... We will get shown the following error: TypeError: Reduce of empty array with no initial value.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-index-of-the-max-value-in-array-of-objects
How to Get Index of the Max Value in Array of Objects ? - GeeksforGeeks
August 5, 2025 - It executes a provided function for each value of the array and accumulates a single result. ... Example: The below code explains the use of the reduce() method to get the index of the max value in an array of objects.
🌐
Linux Hint
linuxhint.com › get-the-max-id-in-an-array-of-objects-in-javascript
Get the Max id in an Array of Objects in JavaScript
November 22, 2022 - Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
TutorialsPoint
tutorialspoint.com › top-n-max-value-from-array-of-object-javascript
Top n max value from array of object JavaScript
August 26, 2020 - We have to write a function that takes in this array and returns the top n element of the array in another array (top means the object that has the highest value for duration).