This is a NodeJS stuff, the code is:
var http = require("http");
function onRequest(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}
http.createServer(onRequest).listen(8888);
My question is how come in the last line, the function onRequest doesn't take parameters.. I'm new to Javascript but isn't onRequest supposed to take 2 parameters as defined in the function? Can anyone help me please? I've been stuck for an hour :(
onRequestis a function object.onRequest()calls the functiononRequestand returns its value.