Learning Links: http://www.cnblogs.com/zhongweiv/p/nodejs_environment.html
(a) Introduction and environmental installation
node. JS is a platform that lets JavaScript out of the browser running on the server, not the language ;
The JavaScript engine used by node. JS is a V8 from Google Chrome; JavaScript compatibility issues that run outside the browser without having to worry about headaches
The use of single-threaded, asynchronous IO and event-driven design to achieve high concurrency (asynchronous events also to some extent increased the difficulty of development and debugging);
node. JS has an HTTP server built in , so it's good news for web development;
(ii) Event module
Events is the most important module of node. js, theEvents module provides only one object, events. The core of Eventemitter,eventemitter is event launch and event listener.
Most of the modules in node. js are inherited from the event module.
Unlike events on the DOM tree, there is no event bubbling, layer-wise capture, and so on.
Eventemitter supports a number of event listeners. When an event is emitted, the event listener registered to the event is called sequentially, and the event arguments are passed as a callback function parameter.
Test source and results are as follows
/*Call the events module to get events. Eventemitter Object*/varEventemitter = require (' Events '). Eventemitter; varEE =NewEventemitter ();/*Eventemitter.on (event, listener) registers a listener parameter 1:event string for the event, event name parameter 2: callback function*/Ee.on (' Some_events ',function(foo, bar) {Console.log ("1th listener event, parameter foo=" + foo + ", bar=" +bar);}); Console.log (' First round '); Ee.emit (' Some_events ', ' Wilson ', ' Zhong '); Console.log (' Second round '); Ee.emit (' Some_events ', ' Wilson ', ' Z ');
Run results
"Nodejs" Study notes