Skip to content

Instantly share code, notes, and snippets.

@unknownuser88
Created July 17, 2015 14:17
Show Gist options
  • Save unknownuser88/6a0301cc835655251930 to your computer and use it in GitHub Desktop.
Save unknownuser88/6a0301cc835655251930 to your computer and use it in GitHub Desktop.
array contains functionality for node js
Array.prototype.contains = function(k, callback) {
var self = this;
return (function check(i) {
if (i >= self.length) {
return callback(false);
}
if (self[i] === k) {
return callback(true);
}
return process.nextTick(check.bind(null, i+1));
}(0));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment