For exmaple, I write the following code:
var http = require('http');
var server = http.createServer(function(req, res) {
res.end('Hello world!');
});
server.listen(8000, function() {
console.log('Serever started');
});
However, the definition of server.listen() is like this:
server.listen(port, hostname, backlog, callback);
listen() method has four parameters while only two parameters port and callback were passed in my code.
How the method knows that function(){console.log('Server started');} is 'callback' and not 'hostname?' Does it automatically check the type of parameters?
No comments:
Post a Comment