JavaScript find min value in Array of objects | Example code

There are many ways to get the min value in an array of objects in JavaScript. Some simple and basic methods are to loop through all elements and compare it to the lowest value or sort the array or Math. min.

Array looks like this:

Examples of JavaScript find min value in array of objects

Example 1 : Loop

One way is to loop through all elements and compare it to the lowest value.

Output:

JavaScript find min value in Array of objects

Example 2: Math.min.apply

Output: Object { min: 1000 }

Example 3: sort()

First sort the JS array with a custom sorting function:

Then take the first-> Minimum and last -> Maximum:

Do comment if you have any doubts and suggestion on this topic.

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.