Skip to content

Instantly share code, notes, and snippets.

@phantom42
Created April 19, 2013 17:38
Show Gist options
  • Save phantom42/5421902 to your computer and use it in GitHub Desktop.
Save phantom42/5421902 to your computer and use it in GitHub Desktop.
custom function to emulate indexOf method which is not supported by some browsers (IE8)
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;
}
}
@Elvanas
Copy link

Elvanas commented Dec 6, 2013

thank you for this life saving code snippet. It works like a charm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment