Created
September 3, 2013 05:38
-
-
Save steppefox/6420058 to your computer and use it in GitHub Desktop.
in_array analog in js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Вхождение в массив | |
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