我有一个jQuery插件在网络应用程序中使用,它在、IE、10、和11中运行良好。但它在IE 7上失败了。当我研究时,我知道filter方法的值是undefined。代码行失败如下:
if (splitters.filter(Boolean).length === 0) {我正在使用jQuery 1.8.3
发布于 2016-06-09 07:32:24
它是JavaScript 过滤器()方法,仅在根据MDN文档提供的IE 9+中支持
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];
// NOTE: Technically this should Object.defineProperty at
// the next index, as push can be affected by
// properties on Object.prototype and Array.prototype.
// But that method's new, and collisions should be
// rare, so use the more-compatible alternative.
if (fun.call(thisArg, val, i, t)) {
res.push(val);
}
}
}
return res;
};
}https://stackoverflow.com/questions/37719487
复制相似问题