Javascript Array clear()
/**//from w w w . j a v a2 s. com * Array#clear() -> Array * * Clears the array (makes it empty) and returns the array reference. * * ##### Example * * var guys = ['Sam', 'Justin', 'Andrew', 'Dan']; * guys.clear(); * // -> [] * guys * // -> [] **/ Array.prototype.clear = function() { this.length = 0; return this; };
Array.prototype.clear = function () { return this.splice( 0, this.length ); };
Array.prototype.clearArray = function(){ while(this.length) this.pop(); };