Array contains:
Array.prototype.contains = function(obj) {
for (var i=0; i < this.length; i++) {
if(this[i] === obj) return i;
}
return -1;
}
Usage:
var arr = [1, 2, 3];
alert(arr.contains(2));
This little helper function tells you if your array contains an object. If it does then the index of the object is returned, otherwise -1 is returned.
Free Friday afternoon tip: don't ever ever ever modify the Object prototype. That would be just asking for a whole world of pain - I learnt this the hard way :)