我的页面上有这个array.prototype,它似乎占用了很多处理时间:
Array.prototype.findInArray = function(searchStr) {
var returnArray = false;
for (i=0; i<this.length; i++) {
if (typeof(searchStr) == 'function') {
if (searchStr.test(this[i])) {
if (!returnArray) { returnArray = [] }
returnArray.push(i);
}
} else {
var regexp = new RegExp(".*" + searchStr + ".*");
if (this[i].match(regexp)) {
if (!returnArray) { returnArray = [] }
returnArray.push(i);
}
}
}
return returnArray;
}