Skip to content

Instantly share code, notes, and snippets.

@kelp404
Last active December 27, 2015 23:49
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 kelp404/7409202 to your computer and use it in GitHub Desktop.
Save kelp404/7409202 to your computer and use it in GitHub Desktop.
Array.prototype.remByVal = function(val) {
for (var i = 0; i < this.length; i++) {
if (this[i] === val) {
this.splice(i, 1);
i--;
}
}
return this;
};
//Call like
[1, 2, 3, 4, 3].remByVal(3);
@kelp404
Copy link
Author

kelp404 commented Nov 11, 2013

Array.prototype.remByVal = (val) ->
  for index in [0..@length - 1] when @[index] is val
    @splice index, 1
    index--
  @

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment