Skip to content

Instantly share code, notes, and snippets.

@namlet
Created March 29, 2012 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namlet/2243012 to your computer and use it in GitHub Desktop.
Save namlet/2243012 to your computer and use it in GitHub Desktop.
Remove an item from an array by value
Array.prototype.remove = function(itemToRemove) {
var i = 0;
while (i < this.length) {
if (this[i] == itemToRemove) {
this.splice(i,1)
} else {
i++;
}
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment