在 Node.js 文档中,我们可以看到:
var util = require("util");
var events = require("events");
function MyStream() {
events.EventEmitter.call(this);
}
util.inherits(MyStream, events.EventEmitter);
var stream = new MyStream();
是否与以下内容相同:
function MyStream2() {
}
//MyStream2 = new events.EventEmitter; WRONG. Thank you @Esailija
MyStream2.prototype = new events.EventEmitter;
var stream2 = new MyStream2();
谢谢 :)