Javascript Array remove( from, to ) method

Description

Javascript Array remove( from, to ) method



/**//from   ww  w .j  a  va 2s. c  o m
 * @module QueenEngine
 * @submodule Array
 */

/**
 * 
 *
 * @method remove
 * @param {Int} from
 * @param {Int} to
 * @example 
 *  var a = [ 3, 4, 5 ];
 *  a.remove( 1 );
 */

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 );
};



PreviousNext

Related