Nodejs Array Remove by Value removeItemByID(element)

Here you can find the source of removeItemByID(element)

Method Source Code

Array.prototype.removeItemByID = function(element)
{
    var found;/*from   w ww.j  a  va 2  s. co m*/
    for (var i = 0; i < this.length; i++)
    {
        if (this[i].id == element.id)
        {
            found = this[i];
            break;
        }
    }
    if (found)
    {
        var index = this.indexOf(found);
        this.splice(index, 1); // Array
    }
};

Related

  1. removeValue(value)
    Array.prototype.removeValue = function(value) {
        for (var n = 0; n < this.length; n++) {
            if (this[n] == value) {
                this.splice(n, 1);
                break;
    
  2. removeValue(value)
    Array.prototype.removeValue = function (value) {
      var index = -1;
      for (var i = 0; i < this.length; i++) {
        if (this[i] == value) {
          this.splice(i,1);
          index = i;
      return index;
    ...
    
  3. removeValue(value)
    var i,
        len,
        arr = [1, 2, 1, 4, 1, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
    Array.prototype.removeValue = function(value) {
        for (i = 0, len = this.length; i < len; i += 1) {
            if (this[i] === value) {
                this.splice(i, 1);
                i -= 1;
    arr.removeValue(1);
    console.log(arr.join(','));
    
  4. removeId(obj)
    Array.prototype.removeId = function(obj) {
      for(var i = 0; i < this.length; i++){
        if(this[i].toString() === obj.toString()){
          this.splice(i, 1);
      return this;
    };
    
  5. removeItem(obj)
    Array.prototype.removeItem = function(obj) {
        var index = this.indexOf(obj);
        if (-1 === index)return;
        this.splice(index, 1);
    };
    
  6. removeItems(value)
    Array.prototype.removeItems = function(value) {
        return this.filter(filterInput);
        function filterInput(v) {
            return v != value;
    var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
    console.log(arr.removeItems(1));
    var arr = ['hi', 'bye', 'hello' ];
    ...
    
  7. removeItemsByValue(value)
    Array.prototype.removeItemsByValue =  function(value){
        for(var i = 0 ; i < this.length ; i++){
            if(this[i] == value ){
                this.splice(i,1);
        return this;
    var a = [1,2,3,4,1,2,"1",5,1];
    ...
    
  8. removeOne(el)
    Array.prototype.removeOne = function (el) {
        var index = this.indexOf(el);
        if (index != -1) {
            this.splice(index, 1);
            return true;
    };
    
  9. removeOneByValue(v)
    Array.prototype.removeOneByValue = function(v) {
        for (let i = this.length - 1; i >= 0; i--)
            if (this[i] === v)
                return this.splice(i, 1);
        return this;
    };