m7v
4/5/2014 - 10:47 AM

Function in_array for JS

Function in_array for JS

  function in_array(needle, haystack, strict) {
    var found = false, key, strict = !!strict;
    for (key in haystack) {
      if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
        found = true;
        break;
      }
    }

    return found;
  }