Skip to content

Instantly share code, notes, and snippets.

@MNBuyskih
Last active August 29, 2015 14:21
Show Gist options
  • Save MNBuyskih/3be329c2c8a3287b9e00 to your computer and use it in GitHub Desktop.
Save MNBuyskih/3be329c2c8a3287b9e00 to your computer and use it in GitHub Desktop.
UnderscoreJS find key in object by predicant
function findKey (obj, predicant) {
var key = null;
_.find(obj, function (v, k) {
if (predicant(v, k, obj)) {
key = k;
return true;
}
return false;
});
return key;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment