Complete the code to import the EventEmitter class from the 'events' module.
const [1] = require('events');
The EventEmitter class is imported from the 'events' module using const EventEmitter = require('events');.
Complete the code to create a new class named MyEmitter that extends EventEmitter.
class MyEmitter extends [1] { constructor() { super(); } }
super() in the constructor.The custom class should extend EventEmitter to inherit event capabilities.
Fix the error in the code to emit a 'start' event from the emitter instance.
const emitter = new MyEmitter(); emitter.[1]('start');
The correct method to emit an event is emit.
Fill both blanks to add a listener for the 'data' event that logs the received message.
emitter.[1]('data', ([2]) => { console.log([2]); });
The on method adds a listener, and the parameter name can be any valid identifier like 'message'.
Fill all three blanks to create an instance, add a listener for 'end', and emit the 'end' event.
const [1] = new MyEmitter(); [1].on('end', () => { console.log('Finished'); }); [1].[2]('end');
Create an instance named 'emitter', use on to add a listener, and emit to trigger the event.