Last active
January 27, 2016 15:27
-
-
Save phongsakornp/72d91befc86d9e1de5e8 to your computer and use it in GitHub Desktop.
#javascript
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
# http://debugmode.net/2013/02/19/how-to-find-index-of-an-item-in-javascript-object-array/ | |
var findIndexByKeyValue = function(arraytosearch, key, valuetosearch) { | |
for (var i = 0; i < arraytosearch.length; i++) { | |
if (arraytosearch[i][key] == valuetosearch) { | |
return i; | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment