JavaScript map max value | Example code

Use spread the values() into Math.max to get max map in JavaScript.

JavaScript map max value Example

HTML example code: Use spread the values() into Math.max:


JavaScript map max value

Another Example

If you need both the key and value, then use reduce() using the entries() method for the map:

Output: Array [ “c”, 6 ]

Q: How to find the max id in an array of objects in JavaScript?

Answer: Get the max value from Object Array, in this example will get by name attribute.

Output: F

Find max of array of objects key using math apply method:

Output: 606

Do comment if you have any doubts and suggestions on this program code/

Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.