What is the difference between the resulting objects in the following examples:
var EventEmitter = require('events').EventEmitter;
var oProto = Object.create(EventEmitter.prototype);
var oProto2 = Object.create(oProto);
var oConstr = Object.create(new EventEmitter);
var oConstr2 = Object.create(oConstr);
I suppose oConstr and oConstr2 will have any properties set in the EventEmitter constructor, but is there any other meaningful difference?
Your code is misleading. you use the term
oConstrwhen it's not a constructor function.The only difference is that
tempis not just an object that inherits fromEventEmitterit also has own properties augmented from the call toEventEmitter.constructor.call(temp).I'd personally recommend you use
EventEmitter.prototypeand ignorenew EventEmitterPersonally I don't ever inherit from
EventEmitter, I mix it in