当前位置: 移动技术网 > IT编程>开发语言>JavaScript > Node.js 函数

Node.js 函数

2020年03月11日  | 移动技术网IT编程  | 我要评论

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

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

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

fn1(name,"cyy");

 

 

使用匿名函数

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

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

 

 

http服务器实例:

var http=require("http");

http.createserver(function(request,response){
    response.writehead(200,{"content-type":"text/plain"});
    response.write("hello http~");
    response.end();
}).listen(8888);

 

 

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网