Skip to content

Instantly share code, notes, and snippets.

@neagle
Created February 27, 2012 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neagle/1927382 to your computer and use it in GitHub Desktop.
Save neagle/1927382 to your computer and use it in GitHub Desktop.
Shim for Array.prototype.indexOf()
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment