20 lines
434 B
JavaScript
20 lines
434 B
JavaScript
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 += 1) {
|
|
if (i in this && this[i]===find) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
};
|
|
} |