Nodejs Array Remove by Index remove(n)

Here you can find the source of remove(n)

Method Source Code

Array.prototype.remove = function(n) {
   this.splice(this.indexOf(n), 1);//w w  w  .  ja  va  2 s  .c  o  m
};

Related

  1. remove(index)
    Array.prototype.remove = function(index)
        this.splice(index,1);
    };
    
  2. remove(index)
    Array.prototype.remove = function(index) {
      this.splice(index, 1);
      return this;
    };
    
  3. remove(index)
    Array.prototype.remove = function(index) {
      return this.splice(index, 1);
    
  4. remove(index)
    'use strict';
    Array.prototype.remove = function (index) {
      return this.splice(index, 1);
    
  5. remove(index)
    Array.prototype.remove=function(index){
      for(var i=0;i<this.length;i++){
        if(i==index){
          this.splice(i, 1);
          break;
    
  6. remove(n)
    Array.prototype.remove = function(n){
      for(var i in this){
        if(this[i]==n){
          this.splice(i,1);
          break;
      return this;
    
  7. remove(pos)
    Array.prototype.remove = function (pos) {
        this.splice(pos, 1);
        return this;
    };
    
  8. remove(pred)
    Array.prototype.remove = function(pred) {
      var removed = this.filter(function(item) {
        return pred(item)
      })
      this.forEach(function(i, index, arr) {
        if (removed.indexOf(i) !== -1) arr.splice(index, 1)
      })
      return removed
    var arr = [1, 2, 3, 4, 5, 6]
    var removed = arr.remove(function(e) {return e % 2 === 0})
    console.log(arr)
    console.log(removed)
    
  9. removeAt( index )
    Array.prototype.removeAt = function( index ){
      if(index>=0 && index<this.length){
        for(var i=index; i<this.length; i++){
          this[i] = this[i+1];
        this.length = this.length-1;
      return this;
    function removeElement(index,array){
      if(index>=0 && index<array.length){
        for(var i=index; i<array.length; i++){
          array[i] = array[i+1];
        array.length = array.length-1;
      return array;