Nodejs Array Remove Object removeObject(object)

Here you can find the source of removeObject(object)

Method Source Code

/**//www . j a  v  a  2s.  co m
 Removes a specific object from the array
 @param object The object to remove
 */
Array.prototype.removeObject = function(object)
{
    for (var i = 0; i < this.length; ++i)
    {
        if (this[i] === object)
        {
            this.remove(i);
            break;
        }
    }
}
/**
 Removes a number of objects from the array
 @param from The first object to remove
 @param to (Optional) The last object to remove
 */
Array.prototype.remove = function(/**Number*/ from, /**Number*/ to)
{
    var rest = this.slice((to || from) + 1 || this.length);
    this.length = from < 0 ? this.length + from : from;
    return this.push.apply(this, rest);
};

Related

  1. removeObject(element)
    Array.prototype.removeObject = function (element) {
        var i = this.indexOf(element);
        if (i != -1) {
            this.splice(i, 1);
    };
    
  2. removeObject(obj)
    Array.prototype.removeObject = function(obj) {
      var index = this.indexOf(obj);
      if(index !== -1) {
        this.splice(index, 1);
    Array.prototype.containsObject = function(obj) {
      return this.filter(item => item === obj).length !== 0;
    
  3. removeObject(obj)
    Array.prototype.removeObject=function(obj){
      for(var i=0;i<this.length;i++){
        if(this[i]==obj){
          this.splice(i, 1);
          break;
    
  4. removeObject(object)
    Array.prototype.removeObject = function(object)
        for (var i = 0; i < this.length; ++i)
            if (this[i] === object)
                this.remove(i);
                break;
    Array.prototype.remove = function( from,  to)
      var rest = this.slice((to || from) + 1 || this.length);
      this.length = from < 0 ? this.length + from : from;
      return this.push.apply(this, rest);
    };
    
  5. removeObject(object)
    Array.prototype.removeObject = function(object)
        for (var i = 0; i < this.length; ++i)
            if (this[i] == object)
                this.remove(i);
                break;
    
  6. removeObject(object)
    Array.prototype.removeObject = function(object)
        for (var i = 0; i < this.length; ++i)
            if (this[i] === object)
                this.remove(i);
                break;
    
  7. removeObject(object)
    Array.prototype.removeObject = function(object)
        for (var i = 0; i < this.length; ++i)
            if (this[i] === object)
                this.remove(i);
                break;
    
  8. removeObject(object)
    Array.prototype.removeObject = function(object)
      for (var i = 0; i < this.length; ++i)
        if (this[i] === object)
          this.remove(i);
          break;
    
  9. removeObjectAtIndex(index)
    Array.prototype.removeObjectAtIndex = function (index){
      var array = this.splice(index);
      array.shift();
      return this.concat(array);