Node.js 函数

前端之家收集整理的这篇文章主要介绍了Node.js 函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

一个函数可以作为另一个函数的参数

function fn1(fn,arg){
    fn(arg);
}

 name(n){
    console.log("i am "+n);
}

fn1(name,"cyy");

 

 

使用匿名函数

(n){
    console.log("i am "+n);
},"cyy2");

 

 

HTTP服务器实例:

var http=require("http");

http.createServer((request,response){
    response.writeHead(200,{"Content-Type":"text/plain"});
    response.write("hello http~");
    response.end();
}).listen(8888);

 

 

 

猜你在找的JavaScript相关文章