JavaScript equivalent of PHP’s in_array()

No, it doesn’t have one. For this reason most popular libraries come with one in their utility packages. Check out jQuery’s inArray and Prototype’s Array.indexOf for examples. jQuery’s implementation of it is as simple as you might expect: If you are dealing with a sane amount of array elements the above will do the trick nicely. EDIT: Whoops. I … Read more