Nodejs Utililty Methods Array Remove Item

List of utility methods to do Array Remove Item

Description

The list of methods to do Array Remove Item are organized into topic(s).

Method

removeItem()
Array.prototype.removeItem = function() {
  for (var item in arguments) { 
    for (var i = 0; i < this.length; i++) {
      if (this[i] === arguments[item]) {
        this.splice(i, 1);
var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
arr.removeItem(1);
console.log(arr);
arr = ['hi', 'bye', 'hello'];
arr.removeItem('bye');
console.log(arr);
removeItem(deleteValue)
Array.prototype.removeItem = function(deleteValue) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] === deleteValue) {
            this.splice(i, 1);
            i--;
    return this;
};
...
removeItem(el)
var numberInput = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
var stringInput = ['hi', 'bye', 'hello' ];
Array.prototype.removeItem = function (el){
    var newArr = [];
    for (var i = 0; i < this.length; i++) {
        if (this[i] !== el){
            newArr.push(this[i]);
    return newArr;
console.log(numberInput.removeItem(1));
console.log(stringInput.removeItem('bye'));
removeItem(index)
Array.prototype.removeItem = function(index) {
  if(isNaN(index) || index > this.length) {
    return false;
    for (var i = 0; i < this.length; i++) {
        if (i > index) {
            this[i-1] = this[i];
    this.length -= 1;
};
removeItem(item)
Array.prototype.removeItem = function(item){
    while(this.indexOf(item) !== -1) {
        this.splice(this.indexOf(item), 1);
    return this;
var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
console.log(arr.removeItem(1));
var arr = ['hi', 'bye', 'hello' ];
...
removeItem(item)
Array.prototype.removeItem = function(item) {
    while (this.indexOf(item) >= 0) {
        this.splice(this.indexOf(item), 1);
    console.log(this);
    return this;
};
var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
arr.removeItem(1);
...
removeItem(item)
Array.prototype.removeItem = function(item){
  for (var i = 0; i < this.length; i++) {
    if (this[i] === item) {
      this.splice(i,1);
      i--;
};
var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
...
removeItem(item)
Array.prototype.removeItem = function(item) {
    var index = this.indexOf(item);
       if(index > -1){
           this.splice(index,1);
    return this;
};
var arr = [1, 2, 1, 4, 1, 3, 4, 1, 111, 3, 2, 1, '1'];
arr = arr.removeItem(1);
...
removeItem(item)
Array.prototype.removeItem = function (item) {
    var result = [];
    for (var i = 0; i < this.length; i++) {
        if (this[i] !== item) {
            result.push(this[i]);
    return result;
};
...
removeItem(item)
Array.prototype.removeItem = function(item) { 
  for(var i = 0, l = this.length; i < l; ++i){
    index = this.indexOf(item);
    if (index > -1) {
      this.splice(index, 1);
  return this;