Created
July 22, 2013 14:31
-
-
Save vkareh/6054262 to your computer and use it in GitHub Desktop.
Add ECMA262-5 indexOf method if not supported natively
Taken from http://stackoverflow.com/questions/2790001/fixing-javascript-array-functions-in-internet-explorer-indexof-foreach-etc
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 (!('indexOf' in Array.prototype)) { | |
Array.prototype.indexOf= function(find, i) { | |
if (i===undefined) i= 0; | |
if (i<0) i+= this.length; | |
if (i<0) i= 0; | |
for (var n= this.length; i<n; i++) | |
if (i in this && this[i]===find) | |
return i; | |
return -1; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment