Created
December 21, 2012 17:20
-
-
Save CacheFactory/4354205 to your computer and use it in GitHub Desktop.
An Underscore.js mix to find object keys by their values
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
_.mixin({ | |
findKeysByValue : function(object,value) { | |
var retVal=[] | |
for(var key in object){ | |
var obj=object[key] | |
if(obj==value){ | |
retVal.push(key) | |
} | |
} | |
return retVal; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment