Return to Snippet

Revision: 18361
at September 29, 2009 06:54 by svenito


Initial Code
Array.prototype.removeItems = function(item) {
	var i = 0;
	while (i < this.length) {
		if (this[i] == item) {
			this.splice(i, 1);
		} else {
			i++;
		}
	}
	return this;
}

Initial URL

                                

Initial Description
This extends arrays withe a removeItems operation to remove all occurances of <item> from <array>
usage: myArray.removeItems("words");

Initial Title
Remove items from array

Initial Tags
array

Initial Language
JavaScript