Get the min and max from array of objects with underscore.js
问题 Let's say I have the following structure var myArrofObjects = [ {prop1:"10", prop2:"20", prop3: "somevalue1"}, {prop1:"11", prop2:"26", prop3: "somevalue2"}, {prop1:"67", prop2:"78", prop3: "somevalue3"} ]; I need to find the min and max based on prop2, so here my numbers would be 20 and 78. How can I write code in Underscore to do that? 回答1: You don't really need underscore for something like this. Math.max(...arrayOfObjects.map(elt => elt.prop2)); If you're not an ES6 kind of guy, then Math