Created
July 17, 2015 14:17
-
-
Save unknownuser88/6a0301cc835655251930 to your computer and use it in GitHub Desktop.
array contains functionality for node js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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