Nodejs Array Delete by Index delete()

Here you can find the source of delete()

Method Source Code

/**//from   w w  w .  j a  v  a 2  s.c  o m
 * @method delete
 * @param {Array} arguments[0] Array with items to remove from trigger array
 * @description Returns array without deleted items
 * @example [3,5,7].delete([2,7,4,3]);
 * @returns {Array} Array without deleted items.
 */

Array.prototype.delete = function() { 
    var arr = this;
    var todel = arguments[0];
    if(todel && todel instanceof Array) {
        var arraux = [];
        for(var i=0; i<todel.length;i++) {
            arr.some(function(el, j){
                if(el == todel[i]){
                    arraux.push(j+'');
                };
                return el == todel[i];
            });
        };
        arraux = arraux.sort();
        for(var i=arraux.length-1;i>=0;i--) {
            arr.splice(arraux[i],1);
        };
        return arr;
    } else {
        return false;
    };
};

Related

  1. delete(index)
    'use strict';
    Array.prototype.delete = function (index) {
        delete this[index];
        this.splice(index, 1);
        return this;
    };
    
  2. deleteAll()
    Array.prototype.deleteAll = function(){
      var arr = this;
      arr.splice(0,arr.length);
    
  3. deleteAt(index)
    Array.prototype.deleteAt = function(index) {
      return this.splice(index, 1);
    };
    
  4. deleteItems(ids, filterEmpty = true)
    Array.prototype.deleteItems = function (ids, filterEmpty = true) {
        var result = this.slice();
        if (typeof ids === 'object' && ids.constructor === [].constructor) {
            ids.sort(function (a, b) {
                return b > a;
            }).forEach(function (value) {
                if (filterEmpty) {
                    result.splice(value, 1);
                } else {
    ...