Removes a number of objects from the array - Node.js Array

Node.js examples for Array:Remove Element

Description

Removes a number of objects from the array

Demo Code

// http://webdemos.sourceforge.net/jsplatformer7/Utils.js

/**/*ww  w  .ja v  a  2s.c  om*/
    Removes a number of objects from the array
    @param from The first object to remove
    @param to (Optional) The last object to remove
*/
Array.prototype.remove = function(/**Number*/ from, /**Number*/ to)
{
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);
};

Related Tutorials