Created
March 28, 2017 22:06
-
-
Save wendellpereira/efa2c830d4c2e79e7c77a12ce67bc116 to your computer and use it in GitHub Desktop.
Search a element by value in a Object Array
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
function arrayObjectIndexOf (key, prop, array) { | |
for (var i=0; i < array.length; i++) { | |
if (array[i][prop] === key) { | |
return i; | |
} | |
} | |
return -1; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment