Array.indexOf does not work in Internet Explorer...So make it!

While trying to do an indexOf on a Javascript array I created [arrayName.indexOf("joe")] I discovered that it wouldn't work in Internet Explorer! IE does not support this method for array's! So A quick search on the web lead me to soledad penadés web site where I discovered a simple solution. All you have to do is add the following chunk of code to your script with no modifications and it will force Internet Explorer to function properly! How cool is that!

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

By Colin Pear, 6/10/2007 -- Back to Java Script Tutorials ans lessons learned.

Works Cited: http://www.soledadpenades.com/2007/05/17/arrayindexof-in-internet-explorer/ — 6/10/2007