Skip to content

Instantly share code, notes, and snippets.

@roaldjap
Forked from jboulhous/findkey.js
Created August 11, 2020 05:49
Show Gist options
  • Save roaldjap/5470908c67d33ca6de45945410e4865b to your computer and use it in GitHub Desktop.
Save roaldjap/5470908c67d33ca6de45945410e4865b 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