Node.js事件和函数

时间:2017-08-03 04:51:17

标签: node.js function events

我一直在学习node.js,我对此有些困惑:

这样:

home.lights.on('on', function(number, room) {  
    console.log('light number %d in room %s was turned on', number, room);
});

和此:

function lightsOn(number, room){
    console.log('light number %d in room %s was turned on', number, room);
}
lightsOn(1,2);

做同样的事情还是他们之间有区别?

0 个答案:

没有答案