Posted by: xcopsgen October 11, 2011
javascript array
Login in to Rate this Post:     0       ?        
Array.prototype.contains = function(obj) {
var i = this.length;
while (i--) {
if (this[i] === obj) {
return true;
}
}
return false;
}
And now you can simply use the following:

alert([1, 2, 3].contains(2)); // => true
alert([1, 2, 3].contains('2')); // => false
Read Full Discussion Thread for this article