Skip to content

Instantly share code, notes, and snippets.

@steppefox
Created September 3, 2013 05:38
Show Gist options
  • Save steppefox/6420058 to your computer and use it in GitHub Desktop.
Save steppefox/6420058 to your computer and use it in GitHub Desktop.
in_array analog in js
//Вхождение в массив
var in_array = function (needle, haystack, strict) {
//original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
var found = false, key, strict = !!strict;
for (key in haystack) {
if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) {
found = true;
break;
}
}
return found;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment