I think it's because any instance of EventEmitter can execute event.prototype.init,. If an existing event executes the init method, it needs to be judged by IF


No usefulness is found in this version. the following is a wild guess .

if (!this._events ...){

}

this part may be historical legacy code, which means if it looks like a duck, swims like a duck, and sounds like a duck, then it is most likely a duck , so it is not re-instantiated. it is recommended to check the historical version and how it is used .

this._maxListeners = this._maxListeners || undefined;

if this._maxListeners is false, it becomes undefined , such as 0/NaN .

Menu