Node.js学习 - Function
2016-04-15 22:41
573 查看
Node.js函数和JavaScript类似
匿名函数
函数传递是如何让HTTP服务器工作的
function say(word) { console.log(word); } function execute(someFunction, value) { someFunction(value); } execute(say, "Hello");
匿名函数
function execute(someFunction, value) { someFunction(value); } execute(function(word){ console.log(word) }, "Hello");
函数传递是如何让HTTP服务器工作的
var http = require("http"); http.createServer(function(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); }).listen(8888); 也可以这样: var http = require("http"); function onRequest(request, response) { response.writeHead(200, {"Content-Type": "text/plain"}); response.write("Hello World"); response.end(); } http.createServer(onRequest).listen(8888);
相关文章推荐
- Node.js学习 - Modules
- Node.js学习 - Stream
- Node.js学习 - Buffer
- Node.js学习 - Event Loop
- Node.js学习 - CallBack Function
- Node 学习笔记之事件发射器
- Node.js学习 - Install and Configure
- 116. Populating Next Right Pointers in Each Node
- Nodejs建站笔记-注册登录流程的简单实现
- 237.LeetCode Delete Node in a Linked List(easy)[单链表 删除节点]
- 使用express(4.X)搭建第一个Web应用【Node.js初学】
- Installing node.js on ubuntu server 15.10
- 『奇葩问题集锦』npm install 报错 node-pre-gyp ERR! node-pre-gyp -v v0.6.25
- node authentication
- Unix Filesystem Organization
- 美团酒店Node全栈开发实践
- 理解Nodejs中的事件轮询机制
- webstorm中使用nodejs,npm 配置
- NodeJS、NPM安装配置步骤
- 错误:namenode无法自动切换成active