Posted By

cornellsteven on 12/31/10


javascript array in inarray

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


javascript in_array

 / Published in: JavaScript

Quick and easy javascript in_array function. It's not perfect, but if you need something quick, this is it.

  1. function in_array(needle, haystack) {
  2. for (var i=0, j=haystack.length; i < j; i++) {
  3. if (needle == haystack[i]) return true;
  4. }
  5. return false;
  6. }

Report this snippet  

You need to login to post a comment.