Javascript Array removeItemsByValue(value)

Description

Javascript Array removeItemsByValue(value)





Array.prototype.removeItemsByValue =  function(value){
    for(var i = 0 ; i < this.length ; i++){

        if(this[i] == value ){
            this.splice(i,1);/*  w w w  .jav a2s .  c om*/
        }

    }

    return this;

}


var a = [1,2,3,4,1,2,"1",5,1];
console.log(a.removeItemsByValue(1));



PreviousNext

Related