function Parent() {}Parent.prototype.sayHello = function () { console.log('Hello. From Parent Class');}function Child() {}util.inherits(Child,Parent); // inherit Relationvar parent = new Parent();parent.sayHello();var child = new Child();child.sayHello();
Event(이벤트)
process.on('exit', function (code) { // 이벤트가 발생할 때마다 동작 console.log('exit event : ', code);})process.once('exit',function (code) { // 이벤트가 첫 번째로 발생했을 때에만 동작 console.log('exit event with once : ', code);})process.emit('exit'); //이벤트 발생시키기process.emit('exit',0);process.emit('exit',1);process.on('uncaughtException',function (code) { //예외처리 되지 않는 상황 console.log('uncaughtException Error');})sayTest();
이벤트 리스너 함수 삭제
emitter.removeListener(event, listener)
emitter.removeAllListener(event)
최대 이벤트 핸들러 개수(Default Value : 10)
emitter.setMaxListener(n)
emitter.getMaxListener()
Error Handle
emitter.on('event',function(error,result){ if(error){ // Handle Error }else{ // 정상 처리 }})