Nodejs Array Remove by Value removeValue(name, value)

Here you can find the source of removeValue(name, value)

Method Source Code

//Remove element from array by key name and value
Array.prototype.removeValue = function(name, value){
   try//from  ww w .  ja  v  a2  s.c  o m
   {
   var array = $.map(this, function(v,i){
      return v[name] === value ? null : v;
   });
   this.length = 0; //clear original array
   this.push.apply(this, array); //push all elements except the one we want to delete
   }
   catch(e)
   {
      console.log(e);
   }
}

Related

  1. removeItem(value)
    "use strict";
    Array.prototype.removeItem = function (value) {
        for (var i in this) {
            if(this[i] === value) {
                this.splice(i, 1);
    };
    var arr = ['hi', 'bye', 'hello' ];
    ...
    
  2. removeItem(value)
    Array.prototype.removeItem = function (value) {
        for (var i = 0; i < this.length; i++) {
            var currElem = this[i];
            if (currElem === value) {
                this.splice(i, 1);
        return this;
    };
    ...
    
  3. removeItem(value)
    Array.prototype.removeItem = function (value) {
        return this.filter(function (v) {
            return v !== value;
        })
    };
    var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
    console.log(arr.removeItem(1));
    arr = ['hi', 'bye', 'hello' ];
    console.log(arr.removeItem('bye'));
    ...
    
  4. removeItem(value)
    Array.prototype.removeItem = function (value) {
        for(var i = this.length-1; i--;){
            if (this[i] === value) {
                this.splice(i, 1)
    };
    var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
    arr.removeItem(1);
    ...
    
  5. removeValue(int)
    Array.prototype.removeValue = function(int) {
      var ans = [];
      var count = 0;
      for (i = 0; i < this.length; i++) {
        if (this[i] !== int) {
          ans.push(this[i]);
        } else if (this[i] === int) {
          count++;
      if (count === 0) {
        return false;
      return ans;
    
  6. removeValue(name, value)
    Array.prototype.removeValue = function(name, value) {
        var array = $.map(this, function(v, i) {
            return v[name] === value ? null : v;
        });
        this.length = 0; 
        this.push.apply(this, array); 
        return this;
    
  7. removeValue(name, value)
    const DATE_FORMAT = 'Do MMM YYYY';
    const DATETIME_FORMAT = 'Do MMM YYYY LT';
    Array.prototype.removeValue = function(name, value){
       var array = $.map(this, function(v,i){
          return v[name] === value ? null : v;
       });
       this.length = 0; 
       this.push.apply(this, array); 
    
  8. removeValue(thing)
    Array.prototype.removeValue = function(thing) {
      for (var i = 0; i < this.length; i++) {
        if(this[i] == thing) {
          this.splice(i, 1);
      return this;
    
  9. removeValue(thing)
    Array.prototype.removeValue = function(thing) {
      if (this.indexOf(thing) === -1) return false;
      var i;
      while ((i = this.indexOf(thing)) > -1) this.splice(i, 1);
      return this;