Skip to content

Instantly share code, notes, and snippets.

@vrutberg
Created June 4, 2009 13:43
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 vrutberg/123618 to your computer and use it in GitHub Desktop.
Save vrutberg/123618 to your computer and use it in GitHub Desktop.
Array.prototype.each = function(callback) {
var i = this.length, j = 0;
while(i--) {
callback.call(this, this[j++]);
}
};
Array.prototype.contains = function(needle) {
var contains = false;
this.each(function(val) {
if(needle === val) contains = true;
});
return contains;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment