What is the difference between:
http.Server(function(req,res) {});
and
http.createServer(function(req, res) {});
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Based on the source code of nodejs (extract below),
createServeris just a helper method to instantiate aServer.Extract from line 1674 of http.js.
So therefore the only true difference in the two code snippets you’ve mentioned in your original question, is that you’re not using the
newkeyword.For clarity the
Serverconstructor is as follows (at time of post – 2012-12-13):