Home > Web Front-end > JS Tutorial > body text

Node.js functions

黄舟
Release: 2017-01-17 15:54:03
Original
1132 people have browsed it

Node.js function

Anonymous function: scope.js

[code]function execute(someFn, value) {
    someFn(value);
}
execute(function (word) {
    console.log(word)
}, 'hello');
Copy after login

Node.js functions


How function passing makes the HTTP service work

Case: server.js

[code]var http = require('http');
var onRequest = function (request, response) {
    response.writeHead(200, { "Content-Type" : "text/plain"});
    response.write("Hello world");
    response.end();
}
http.createServer(onRequest).listen(8888);
console.log('服务器监听端口 8888');
Copy after login

Node.js functions

Client: http://localhost:8888/%E5%87%BD%E6%95%B0/server. js

Node.js functions

#The above is the content of the Node.js function. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!