Sometimes I see JavaScript that is written with an argument provided that already has a set value or is an object with methods. Take this jQuery example for instance:
If you looked at the code for createServer, it'd look something like this:
function createServer (handleRequestAndResponseFunction) {
handleRequestAndResponseFunction(actualRequest, actualReponse);
}
ok, no it wouldn't, but it's a simple example. createServer takes a function
that accepts two arguments.
In more realistic terms, when you pass in that function of two arguments, it does whatever middleware processing and stuff that it needs to, and then calls that function, passing its own request and response variables.