1. 程式人生 > >JS根據數組下表刪除元素

JS根據數組下表刪除元素

proto blog 根據 temp fun isn prot pan i++

//新增根據數組下表remove元素方法
    Array.prototype.remove = function(obj){
        
        for(var i=0;i<this.length;i++){
            var temp = this[i];
            if(!isNaN(obj)){
                temp=i;
            }
            if(temp == obj){
                for(var j=i ;j<length;j++){
                    
this[j] = this[J+1]; } this.length = this.length-1 ; } } }

JS根據數組下表刪除元素