Javascript Array del(index)

Description

Javascript Array del(index)


Array.prototype.del=function (index) {
    var newArr=[];
    for(var i=0;i<this.length;i++){
        if(i==index)continue;
        newArr.push(this[i]);//www  . j  a v  a 2s .  c o m
    }
    return newArr;
};

Javascript Array del(index)

Array.prototype.del = function(index){
    if(isNaN(index) || index > this.length || index < 0){
        return false;
    }//from   w w w.j av a2  s  .c  o m
    this.splice(index,1);
}



PreviousNext

Related