Created
March 30, 2016 12:22
-
-
Save O5ten/892508ff077ebff571b9d5f17c5a0f89 to your computer and use it in GitHub Desktop.
indexOf by condition instead of deep-equal
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
indexOf = function(collection, condition){ | |
if(collection && Array.isArray(collection) && condition){ | |
for(var i = 0; i < collection.length; i+=1){ | |
if(condition(collection[i])){ | |
return i; | |
} | |
} | |
} | |
return -1; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment