Node.js examples for Array:Remove Element
Remove all element from array
Array.prototype.removeAll = function( func ) { var _retained = []; var _removed = []; for( var i=0; i<this.length; i++ ) { var item = this[i]; if( !func(item) == true ) { _retained.push( item );/* w ww .j a v a 2s. c o m*/ } else { _removed.push( item ); } } this.length = 0; this.push.apply(this, _retained); return _removed; };