title: How to fix Array indexOf() in JavaScript for Internet Explorer browsers
body: <p>If you have worked with JavaScript at any length you are aware that Internet&nbsp;Explorer does not implement the ECMAScript function for Array.prototype.indexOf() [including Internet&nbsp;Explorer&nbsp;8]. It is not a huge problem, because you can extend the functionality on your page with the following code.</p>
  
  <pre><code>Array.prototype.indexOf = function(obj, start) {
       for (var i = (start || 0), j = this.length; i &lt; j; i++) {
           if (this[i] === obj) { return i; }
       }
       return -1;
  }
  </code></pre>
  
  <p>When should I implement this?</p>
  
  <p>Should I wrap it on all my pages with the following check, which checks if the prototype function exists and if not, go ahead and extend the Array prototype?</p>
  
  <pre><code>if (!Array.prototype.indexOf) {
  
      // Implement function here
  
  }
  </code></pre>
  
  <p>Or do browser check and if it is Internet&nbsp;Explorer then just implement it?</p>
  
  <pre><code>//Pseudo-code
  
  if (browser == IE Style Browser) {
  
       // Implement function here
  
  }
  </code></pre>