Problem Statement
What is an EventEmitter in Node.js?
Explanation
EventEmitter is a core module that allows objects to emit and listen for events. It forms the base for asynchronous communication in Node.js. You can register listeners with `.on()` and trigger them with `.emit()`.
Code Solution
SolutionRead Only
const EventEmitter=require('events');
const emitter=new EventEmitter();
emitter.on('greet',()=>console.log('Hello!'));
emitter.emit('greet');