IE不兼容findIndex

 var arr = [
        {id: 1, name: 'java'},
        {id: 2, name: 'c++'},
        {id: 3, name: 'js'},
        {id: 4, name: 'c#'}
    ]
    // ES6 chorome兼容
    var domIndex = '2'
    var spliceIdex;
    arr.findIndex((item,index)=>{
    	if(domIndex == index){
    		return spliceIdex= index;
    	}
    });
    arr.slice(spliceIdex,1); 
    
    // JS   chorome AND  IE  兼容
    Array.prototype._find_ = function(cb){
        for(var i=0; i< this.length; i++){
            if(cb(this[i],i)){
                return this[i];
            }
        }
    }
   arr._find_(function (item, index){
   		if(domIndex == index){
    		return spliceIdex= index;
    	}
    })
   arr.slice(spliceIdex,1);

更多可参考 点击此处

你可能感兴趣的:(IE不兼容findIndex)