In JavaScript, functions can be passed into methods as a parameter. Example:
function funcA(data) {
console.log(data);
}
function funcB(foo) {
foo('I'm function B'); // Call 'foo' and pass a parameter into that function
}
funcB(funcA); // Pass funcA as a parameter into funcB
What you're doing with http.createServer
is the above, passing a function that can accept parameters. A new server expects you to pass in a function that it can call. The server will do internal actions which it will create a request and response object, and then call the function you passed in with those variables.
Read about the Http Event: Request for details about these parameters.