Nodejs Array Remove by Value removeValue(name, value)

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

Method Source Code

const DATE_FORMAT = 'Do MMM YYYY';
const DATETIME_FORMAT = 'Do MMM YYYY LT';

// remove entry from array
Array.prototype.removeValue = function(name, value){
   var array = $.map(this, function(v,i){
      return v[name] === value ? null : v;
   });//w w  w  . j  a  v a  2  s.c  om
   this.length = 0; //clear original array
   this.push.apply(this, array); //push all elements except the one we want to delete
}

Related

  1. 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'));
    ...
    
  2. 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);
    ...
    
  3. 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;
    
  4. removeValue(name, value)
    Array.prototype.removeValue = function(name, value){
      try
       var array = $.map(this, function(v,i){
          return v[name] === value ? null : v;
       });
       this.length = 0; 
       this.push.apply(this, array); 
      catch(e)
        console.log(e);
    
  5. 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;
    
  6. 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;
    
  7. 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;
    
  8. removeValue(val)
    Array.prototype.removeValue = function(val) {
      var index = this.indexOf(val);
      if (index > -1) {
        this.splice(index, 1);
    };
    
  9. removeValue(value)
    Array.prototype.removeValue = function(value) {
        for (var n = 0; n < this.length; n++) {
            if (this[n] == value) {
                this.splice(n, 1);
                break;