Remove object from Array - Node.js Array

Node.js examples for Array:Remove Element

Description

Remove object from Array

Demo Code


Array.prototype.remove = function(obj) {
  for(var i=0; i<this.length; i++) {
    if(this[i] === obj) {
      this.splice(i, 1);/*w  w w  . j a v  a  2s.co m*/
      return true;
    };
  };
  return false;
};

Related Tutorials