在Hello World示例中,Node.JS的方式令人困惑

这里是Node.JS的大多数书籍中给出的典型hello world示例 –

var http = require('http'); http.createServer(function (req, res) { res.**writeHead**(200, {'Content-Type': 'text/plain'}); res.**end**('Hello World\n'); }).listen(8124, "127.0.0.1"); 

我可以理解,通过“要求”的HTMLfunction已经被放入了var http。 所以.createserver函数将被写入该模块,作为callback参数,我们传递一个匿名函数。 但是,“writehead”和“end”是在哪里定义的? 究竟是什么?