ringa_lee
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!
It will loop infinitely until the stack overflows... and then the process will be killed. Then there is no more...
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!
It will loop infinitely until the stack overflows... and then the process will be killed. Then there is no more...