Could you describe how to create an event emitter class in JavaScript, specifically focusing on the methods on, emit, and off?

Free for the first 3 answer contributors

Interview question asked to Frontend Engineers interviewing at Meta, Canon, Toshiba and others: Could you describe how to create an event emitter class in JavaScript, specifically focusing on the methods on, emit, and off?.