Javascript Array removeById(id)

Description

Javascript Array removeById(id)


Array.prototype.removeById = function(id) {
    for (let index = 0; index < this.length; index++) {
        if (this[index].id === id) {
            this.splice(index, 1);/*  ww  w.j ava 2s .c om*/
            break;
        }
    }
}

Javascript Array removeById(id)

Array.prototype.removeById = function(id) {
 for(var i = 0 ; i < this.length ; i++) {
  if(this[i].id == id) {
   this.splice(i,1);/*from  w  w w.j  av a 2  s . c o m*/
   break;
  }
 }
};



PreviousNext

Related