Skip to content

Instantly share code, notes, and snippets.

@jboulhous
Forked from mxriverlynn/findkey.js
Created November 21, 2012 11:44
Show Gist options
  • Save jboulhous/4124491 to your computer and use it in GitHub Desktop.
Save jboulhous/4124491 to your computer and use it in GitHub Desktop.
Find key by value, with underscore.js
function findKey(obj, value){
var key;
_.each(_.keys(obj), function(k){
var v = obj[k];
if (v === value){
key = k;
}
});
return key;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment