Skip to content

Instantly share code, notes, and snippets.

@rexcfnghk
Last active July 1, 2016 14:48
Show Gist options
  • Select an option

  • Save rexcfnghk/a4a1c9898e6239b97ba7659d1e6ef76a to your computer and use it in GitHub Desktop.

Select an option

Save rexcfnghk/a4a1c9898e6239b97ba7659d1e6ef76a to your computer and use it in GitHub Desktop.
var http = require('http');
function makeResponseHandler(i) {
return function(response) {
console.log('i: ' + i);
};
}
var i = 0,
urls = [ 'http://www.google.com', 'http://www.yahoo.com' ],
urlLength = urls.length;
for (; i < urlLength; i++) {
http.get(urls[i], makeResponseHandler(i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment