http.createServer(app)与app()的区别

第一种写法:

var express = require(‘express’);

var app = express(); 

app.listen(3000);

第二种写法:

var express = require(‘express’);

var http = require(‘http’);

var app = express();

http.createServer(app).listen(80);

区别:

app就是一个:

function (req, res) {}

同时具备一个属性:

app.listen = function (port) {
  http.createServer(this).listen(port);
};

转载于:https://www.cnblogs.com/dabinglian/p/6874290.html

你可能感兴趣的:(http.createServer(app)与app()的区别)