Skip to content

Instantly share code, notes, and snippets.

@pauliusuza
Created January 29, 2012 21:58
Show Gist options
  • Save pauliusuza/1700902 to your computer and use it in GitHub Desktop.
Save pauliusuza/1700902 to your computer and use it in GitHub Desktop.
Recursive Function Pattern in JS
arr = [];
(function recurse(url, i) {
getNextUrl(url, function(err, nextUrl) {
if (!err) {
arr.push(nextUrl);
if (i < 100) recurse(nextUrl, i++);
}
});
}("", 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment