Skip to content

Instantly share code, notes, and snippets.

@devarda
Created December 27, 2019 14:00
Show Gist options
  • Save devarda/221598c86a6ccad6a039f232f4d604f5 to your computer and use it in GitHub Desktop.
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.
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