Created
November 8, 2016 13:37
-
-
Save imbdb/4e1697a96911d180e6e3ce821a8b65a8 to your computer and use it in GitHub Desktop.
JS function to get index of json object in array
This file contains hidden or 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
//Usage | |
//jsonSearch(jsonArray,{'key':'value}) | |
var jsonSearch = function(json_array,needle){ | |
return json_array.map(function(d) { return d[Object.keys(needle)[0]]; }).indexOf(needle[Object.keys(needle)[0]]) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment