Node.js · Junior · Question 42 of 75
Is emitter.emit() synchronous or asynchronous?
- 1Asynchronous: listeners run on the next event loop tick
- ✓Correct answer: Synchronous: all listeners run immediately, in the order they were added
- 3It depends on the event name
Explanation
emit calls listeners one by one before it returns. A slow listener therefore blocks the code that emitted the event.