This is a fork of a function by MathRobin. It's a bit longer, but it's made to work in older browsers that don't support indexOf.
Created
March 23, 2012 19:22
-
-
Save williammalo/2174082 to your computer and use it in GitHub Desktop.
Determine if a value is in a 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(a,b,c,d){for(c in b)d|=b[c]===a;return!!d} |
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
var inArray = function(a,b,c,d){for(c in b)d|=b[c]===a;return!!d} | |
document.write(inArray("foo",["foo","bar","lorem","ipsum"])) | |
//will write true on the page |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! Check the latest revision, with the update by jed and all the explanations needed ;)
https://gist.github.com/2171362