Removes all elements with values contained in the given array - Node.js Array

Node.js examples for Array:Remove Element

Description

Removes all elements with values contained in the given array

Demo Code


// Removes all elements with values contained in the given array
Array.prototype.removeAll = function(values){
    var ind;/* w ww .j a  v  a  2s  .  c  o m*/
    for(var i=0; i < values.length; i++){
        ind = this.indexOf(values[i]);
        while(ind > -1){
            this.remove(ind);
            ind = this.indexOf(values[i]);
        }
    }
}

Related Tutorials