黄舟2017-04-17 16:19:55
const EventEmitter = require('events');
let emitter = new EventEmitter();
let n=1;
emitter.on('myEvent', () => {
console.log(n++);
***emitter.emit('myEvent');***
});
***emitter.emit('myEvent')***;
There are two emitter.emit('myEvent');
Call event, the event itself also has a calling event, which creates a cycle. Finally, the call stack size is consumed and terminated.
For reference.
Love MongoDB! Have Fun!
伊谢尔伦2017-04-17 16:19:55
It will loop infinitely until the stack overflows... and then the process will be killed. Then there is no more...