Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • 86
    Could you expand this answer to show how to return the object that the max value was found in? That would be very helpful, thanks! Commented Sep 12, 2014 at 21:27
  • 26
    Here is the fiddle! hope this will help to someone jsfiddle.net/45c5r246 Commented May 20, 2015 at 11:27
  • 36
    @MikeLyons if you still care about getting the actual object: jsfiddle.net/45c5r246/34 Commented Jul 3, 2015 at 0:45
  • 18
    FWIW my understanding is when you call apply on a function it executes the function with a specified value for this and a series of arguments specified as an array. The trick is that apply turns the array into a series of actual function arguments. So in this case it finally calls Math.max(0.0265, 0.0250, 0.024, 0.031) with the this of the function executed being Math. I can't see why it should be Math frankly, I don't think the function requires a valid this. Oh and here is a proper explanation: stackoverflow.com/questions/21255138/… Commented Aug 18, 2016 at 14:12
  • 7
    Math.max(...array.map(o => o.y)) <3 thx to atom code formatter Commented May 21, 2017 at 18:42