Nodejs Array Remove All removeAll(element)

Here you can find the source of removeAll(element)

Method Source Code

/**//  w  w w.j  a  v a2 s.co  m
 * Removes all occurences of the given element from the list.
 *
 * @param element the element to remove.
 */
Array.prototype.removeAll = function(element) {
   for(var i=0; i<this.length; i++) { 
        if(this[i] === element) {
           this.splice(i,1);
           i--;
        }
   }
}

Related

  1. removeAll( func )
    Array.prototype.removeAll = function( func ) {
      var _retained = [];
      var _removed = [];
      for( var i=0; i<this.length; i++ ) {
        var item = this[i];
        if( !func(item) == true ) {
          _retained.push( item );
        else {
    ...
    
  2. removeAll()
    Array.prototype.removeAll = function () {
        while (this.length > 0) {
            this.pop();
    };
    
  3. removeAll()
    Array.prototype.removeAll = function() {
        while(this.length > 0) {
            this.pop();
    };
    
  4. removeAll(element)
    var arr = [1,2,1,4,1,3,4,1,111,3,2,1,'1'];
    Array.prototype.removeAll = function (element){
        var i,
            length = this.length;
        for (i = 0; i < length; i+=1){
            if(this[i] === element){
                this.splice(i, 1);
                i-=1;
                length-=1;
    ...
    
  5. removeAll(element)
    Array.prototype.removeAll = function (element) {
        var newArr = [];
        for (var i in this) {
            if (this[i] != element) {
                newArr.push(this[i]);
        return newArr;
    var arr = [1, 2, 1, 4, 1, "1", 3, 4, 1, 111, 3, 2, 1, "1"];
    var finalArr = arr.removeAll(1);
    for (var i in finalArr) {
        console.log(finalArr[i]);
    
  6. removeAll(elements)
    Array.prototype.removeAll = function(elements) {
      for (var i = 0; i < elements.length; i++) {
        this.remove(elements[i]);
    };
    
  7. removeAll(item)
    Array.prototype.removeAll = function (item) {
      var removed = []
      for (var i = 0, x = this.length; i < x; i++) {
        if (this[i] === item) {
          removed.push(item)
          this.splice(i, 1)
          i--
      return removed
    var colors = ['red', 'red', 'yellow', 'red']
    for (p in colors) {
      console.log(p)
    
  8. removeAll(items)
    Array.prototype.removeAll = function(items){
      for (var i=0; i<items.length; i++){
        this.remove(items[i]);
      return true;
    
  9. removeAll(obj)
    Array.prototype.removeAll = function(obj) {
      var newArr = new Array();
      var len = this.length;
      for(var i = 0; i < len; i++) {
        if(this[i] != obj)
          newArr.push(this[i]);
      this = newArr;
      return this;
    ...