Nodejs Array Delete by Index deleteAll()

Here you can find the source of deleteAll()

Method Source Code

Array.prototype.deleteAll = function(){
   var arr = this;
   arr.splice(0,arr.length);//from   www .j  a  v  a  2 s .c  o  m
}

Related

  1. delete()
    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+'');
    ...
    
  2. delete(index)
    'use strict';
    Array.prototype.delete = function (index) {
        delete this[index];
        this.splice(index, 1);
        return this;
    };
    
  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 {
    ...
    
  5. delete_at(from, to)
    Array.prototype.delete_at = 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);
    Array.prototype.delete_if = function(matcher){
      for(var i = 0; i < this.length; i++){
        if(matcher(this[i])) {
          this.delete_at(i)
    ...