There is no Array.indexOf in IE?

Who knew!! Apparently mozilla and this guy.

After finishing hours of development on a mapping application at work and finally working all the bugs out, I open it up in IE only to have it crumb to it's knees at the first sign of indexOf. Well thankfully there are people smarter than me out there who had a nifty prototype I just had to throw in to make the application come back to life:

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

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Copyright © mrconnerton.com, 2008-2010. All Rights Reserved