Nodejs Array Remove From To remove(from, to)

Here you can find the source of remove(from, to)

Method Source Code

function print(str) {
  console.log(str);/*www.  j  av a 2 s  .  c o  m*/
}

Array.prototype.remove = function(from, to) {
  var rest = this.slice( (to || from) + 1 || this.length);
  console.log("rest:"+ rest);

  this.length = from < 0 ? this.length + from : from;

  console.log("this:" + this);
  return this.push.apply(this, rest);
}


var array = ["one", "two","three","four","five","six"];

print(array);

array.remove(1,2);
print(array);

Related

  1. remove(from, to)
    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);
    };
    
  2. remove(from, to)
    Array.prototype.remove = function(from, to) {
      if (typeof from != "number") return this.remove(this.indexOf(from));
      var rest = this.slice((to || from) + 1 || this.length);
      this.length = from < 0 ? this.length + from : from;
      return this.push.apply(this, rest);
    };
    
  3. remove(from, to)
    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);
    };
    function map(val, start_min, start_max, end_min, end_max) {
      return (val-start_min)/(start_max-start_min)*(end_max-end_min)+end_min;
    
  4. remove(from, to)
    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);
    };
    function throwNullOrUndefined(obj, message) {
      if (obj == null || typeof obj == "undefined")
        throw message;
    
  5. remove(from, to)
    'use strict';
    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);
    };
    
  6. remove(from, to)
    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);
    };
    var RAD2DEG = 180/Math.PI;
    var DEG2RAD = 1/RAD2DEG;
    
  7. remove(from, to)
    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);
    };
    
  8. remove(from, to)
    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);
    };
    
  9. remove(from, to)
    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);
    };
    function str2list(s){
        if (s) {
            a = s.split(",");
            for (i = 0; i < a.length ; i++) { if (! a[i]) { a.pop(i); } }
    ...