Skip to content

Instantly share code, notes, and snippets.

@E01T
Created July 13, 2013 07:23
Show Gist options
  • Save E01T/5989790 to your computer and use it in GitHub Desktop.
Save E01T/5989790 to your computer and use it in GitHub Desktop.

Revisions

  1. E01T created this gist Jul 13, 2013.
    15 changes: 15 additions & 0 deletions array_index_of.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    /*
    If you have worked with JavaScript at any length you are aware that IE does not implement
    the ECMAScript function for Array.prototype.indexOf() [including IE8]. Not a huge problem
    because you can extend the functionality on your page with the following code.
    */
    if (!Array.prototype.indexOf) {

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

    }