JavaScript equivalent of PHP’s in_array() – Stack Overflow


function inArray(needle, haystack) {

var length = haystack.length;

for(var i = 0; i < length; i++) {

if(haystack[i] == needle) return true;

}

return false;

}

via JavaScript equivalent of PHP’s in_array() – Stack Overflow.

Comments

comments

Leave a Reply

Your email address will not be published.