Created
December 27, 2019 14:00
-
-
Save devarda/221598c86a6ccad6a039f232f4d604f5 to your computer and use it in GitHub Desktop.
Neat one liner to get the minimum of [ {x:1}, {x:2}, {x:3} ]. Minimum of Array of Objects, specific key.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = [ {x:1}, {x:2}, {x:3} ]; | |
let min = Math.min.apply(Math, arr.map(o => o.x)); | |
console.log('Minimum is", min); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment