让低版本IE兼容ES5中数组方法forEach/map/every/some/filter

Array.prototype.some()

if(!Array.prototype.some){  
    Array.prototype.some=function(fun,thisp){
        if(this===undefined||this===null){
            throw new TypeError("Cannot read prototype 'some' of " + this);
        }
        if({}.toString.call(fun)!=="[object Function]"){
            throw new TypeError(fun + " is not a function");
        }
        var t=Object(this);
        var len=t.length >>> 0;
        var thisp=thisp;
        for (var i=0; i<len; i++){
            if({}.hasOwnProperty.call(t,i)&&fun.call(thisp,t[i],i,t)){
                return true;
            }
        }
        return false;

    };
}

Array.prototype.every

if(!Array.prototype.every){  
    Array.prototype.every=function(fun,thisp){
        if(this===null||this===undefined){
            throw new TypeError("Cannot read prototype 'every' of " + this);
        }
        if({}.toString.call(fun)!=="[object Function]"){
            throw new TypeError(fun + " is not a function");
        }
        var t=Object(this);
        var len=t.length >>> 0;
        var thisp=thisp;
        for (var i=0; i<len; i++){
            if({}.hasOwnProperty.call(t,i)&&!fun.call(thisp,t[i],i,t)){
                return true;
            }
        }
        return false;
    }
}

Array.prototype.forEach

if(!Array.prototype.forEach){  
    Array.prototype.forEach=function(fun,thisp){
        if(this===null||this===undefined){
            throw new TypeError("Cannot read prototype 'every' of " + this);
        }
        if({}.toString.call(fun)!=="[object Function]"){
            throw new TypeError(fun + " is not a function");
        }
        var t=Object(this);
        var len=t.length >>> 0;
        var thisp=thisp;
        for (var i=0; i<len; i++){
            if({}.hasOwnProperty.call(t,i)){
                fun.call(thisp,t[i],i,t);
            }
        }
    }
}

Array.prototype.filter

if(!Array.prototype.filter){  
    Array.prototype.filter=function(fun,thisp){
        if(this===null||this===undefined){
            throw new TypeError("Cannot read prototype 'every' of " + this);
        }
        if({}.toString.call(fun)!=="[object Function]"){
            throw new TypeError(fun + " is not a function");
        }
        var t=Object(this);
        var len=t.length >>> 0;
        var thisp=thisp;
        var res=[];
        for (var i=0; i<len; i++){
            if({}.hasOwnProperty.call(t,i)){
                var val=t[i];
                if(fun.call(thisp,val,i,t)){
                    res.push(t[i]);
                }
            }
        }
        return res;
    }
}

Array.prototype.map

if(!Array.prototype.map){  
    Array.prototype.map=function(fun,thisp){
        if(this===null||this===undefined){
            throw new TypeError("Cannot read prototype 'every' of " + this);
        }
        if({}.toString.call(fun)!=="[object Function]"){
            throw new TypeError(fun + " is not a function");
        }
        var t=Object(this);
        var len=t.length >>> 0;
        var thisp=thisp;
        var res=new Array(len);
        for (var i=0; i<len; i++){
            var val,resVal;
            if({}.hasOwnProperty.call(t,i)){
                val=t[i];
                resVal=fun.call(thisp,val,i,t);
                res[i]=resVal;
            }
        }
        return res;
    }
}