if (!Array.prototype.filter){
Array.prototype.filter = function(fun /*, thisArg */){
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var res = [];
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++){
if (i in t){
var val = t[i];
if (fun.call(thisArg, val, i, t))
res.push(val);
}
}
return res;
};
}
if (!Array.prototype.filter){
Array.prototype.filter = function(fun /*, thisArg */){
"use strict";
if (this === void 0 || this === null)
throw new TypeError();
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== "function")
throw new TypeError();
var res = [];
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++){
if (i in t){
var val = t[i];
if (fun.call(thisArg, val, i, t))
res.push(val);
}
}
return res;
};
}
发布评论
评论(2)
引用来自“小米1120”的评论
把这段代码放进脚本就可以了:
把这段代码放进脚本就可以了: