To get min from map in JavaScript use sort method. Array values will be changed.
JavaScript map min value Example
HTML example code:
First sorting an Array by value and then get zero index value. It will be min map value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!DOCTYPE HTML> <html> <body> <script> var myArray = [ {"ID": 1, "Cost": 200}, {"ID": 2, "Cost": 1000}, {"ID": 3, "Cost": 50}, {"ID": 4, "Cost": 500} ]; myArray.sort(function (a, b) { return a.Cost - b.Cost }) var min = myArray[0]; console.log(min); </script> </body> </html> |
Output:

Do comment if you have any doubts and suggestions on this JS map topic
Note: All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version