Broken indexOf in internet explorer

Since IE 7 it’s seems indexOf for arrays is no longer available, here’s a short snippet to fix it:

if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i<this.length; i++){
			 if(this[i]==obj){
				 return i;
			}
		}
		return -1;
	}
}

Categories