Node.js is a platform built on the Chrome JavaScript runtime.

Node.js is an event-driven I/O server-side JavaScript environment based on Google's V8 engine. The V8 engine executes Javascript very quickly and has very good performance.

Node.js EventEmitter syntax

Node.js All asynchronous I/O operations will send an event to the event queue when completed.

Many objects in Node.js will emit events: a net.Server object will emit an event every time there is a new connection, and a fs.readStream object will emit an event when the file is opened. All of these event-generating objects are instances of events.EventEmitter.

Node.js EventEmitter example

//event.js file

var EventEmitter = require('events').EventEmitter; 
var event = new EventEmitter(); 
event.on('some_event', function() {     console.log('some_event 事件触发'); }); 
setTimeout(function() {     event.emit('some_event'); }, 1000);