Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Determine if a value is in a array

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.

function(a,b,c,d){for(c in b)d|=b[c]===a;return!!d}
var inArray = function(a,b,c,d){for(c in b)d|=b[c]===a;return!!d}
//will write true on the page

This comment has been minimized.

Copy link

commented Mar 24, 2012

Hey! Check the latest revision, with the update by jed and all the explanations needed ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.