Event Emitter node.js 에서 이벤트를 발생시키고 처리하는 방식인 EventEmitter객체를 상속받아 구현 우선 node.js api 문서를 보고 따라해본다.https://nodejs.org/dist/latest-v7.x/docs/api/events.html#events_eventsvar events = require('events'); var myEmitter = new events.EventEmitter(); // listener 등록 myEmitter.on('customEvent', function(msg) { console.log(msg); }); // event 호출 myEmitter.emit('customEvent', 'Hello EventEmitter'); // 결과값 : H..
Modules node.js application 만들 때 많은 모듈들을 사용하는데 함수표현(function expressions)에 대해 알아보자. ▶ 함수표현 (function expressions) function callName(name) { name(); } // function expressions var person = function() { console.log('Jason'); } callName(person); // 결과값 JasoncallName() 함수 호출시 변수로 지정된 person을 argument로 지정한다.그럼 선언적 함수(function declarations)로 지정된 callName에 name이라는 parameter 값에 person을 대입한다.결과적으로는 person..