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 - This means that you can use the map function to get an array of id's and then pass it into the max() function using the spread operator. assert(Math.max(...characters.map(user => user.id)) === 444); Spread syntax allows an iterable such as an ...
🌐
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.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › max
Math.max() - JavaScript | MDN
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).
🌐
Seanconnolly
seanconnolly.dev › javascript-find-element-with-max-value
How to get the element with the max value in a JavaScript array · Sean Connolly
Let's apply Array.reduce to our use case to find the max value element in our array. const playerWithMostWins = players.reduce( (prev, current) => { return prev.wins > current.wins ? prev : current } ); And if you need to change the logic to the player with the least wins (for the wall of shame?), it's the same function but just with a different comparison function:
🌐
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)). ... 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 ...
🌐
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.
🌐
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.
🌐
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 (...) in the call to the Math.max() method. The Math.max() method expects comma-separated numbers as parameters, so we can't directly pass it an array. ... We used the spread syntax (...) to unpack the values of the ...
Find elsewhere
🌐
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 ...
🌐
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 ?
When working with objects, we often need to search for the max value of an attribute in an array of objects. We can use various javascript inbuilt functions like reduce() method, and map() method and we can also use a simple for loop to search for the max value.
🌐
W3Schools
w3schools.com › jsref › jsref_max.asp
JavaScript Math max() Method
❮ Previous JavaScript Math Object ... 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....
🌐
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
🌐
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 › max-min-value-of-an-attribute-in-an-array-of-objects-in-javascript
Max/Min value of an attribute in an array of objects in JavaScript | GeeksforGeeks
July 13, 2023 - If each object in the array has a specific key-value structure, you can map it accordingly.JavaScriptcon ... Here are the different ways to select min/max dates in an array using JavaScript1. Using Math.max and Math.minUse Math.max and Math.min function to get the maximum and minimum dates respectively.JavaScriptlet dates = [ new Date("2019/06/25"), new Date("2019/06/26"), new Date("2019/06/27"), new Date(
🌐
TutorialsPoint
tutorialspoint.com › top-n-max-value-from-array-of-object-javascript
Top n max value from array of object JavaScript
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).
🌐
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.
🌐
JavaScript in Plain English
javascript.plainenglish.io › how-to-find-the-max-value-of-a-property-in-an-array-of-javascript-objects-b2e0c7dbb2ff
How to Find the Max value of a Property in an Array of JavaScript Objects? | by John Au-Yeung | JavaScript in Plain English
September 18, 2021 - Then we use the spread operator to spread all the values into the Math.max method as arguments. Then we get that max is 0.031004457 since this is the biggest value in the whole list.