Revision: 9017
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 17, 2008 08:38 by kouphax
Initial Code
/** * Remove all passed in items from the current array. If they * dont exist they are ignored. */ Array.prototype.remove = function(a){ // Array Remove - By John Resig (MIT Licensed) var r = function(from, to) { if(from != -1){ var rest = this.slice((to || from) + 1 || this.length); this.length = from < 0 ? this.length + from : from; return this.push.apply(this, rest); } }; for(var i=0; i<a.length;i++){ r.call(this, this.indexOf(a[i])) } return this; } /** non prototype extending method ---------------------------- */ Array.remove = function(t, a){ // Array Remove - By John Resig (MIT Licensed) var r = function(from, to) { if(from != -1){ var rest = this.slice((to || from) + 1 || this.length); this.length = from < 0 ? this.length + from : from; return this.push.apply(this, rest); } }; for(var i=0; i<a.length;i++){ r.call(t, t.indexOf(a[i])) } return t; }
Initial URL
Initial Description
remove(array) --> array Array.remove(a) simply removes all the items in the passed in array from the current scope array. Good for bulk operations.
Initial Title
Array Remove Function
Initial Tags
javascript, array
Initial Language
JavaScript