Created
April 19, 2013 17:38
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
thank you for this life saving code snippet. It works like a charm