Intermediate Code Reading #OOP #classes #TypeScript

🏗️ Classes & Objects

3 exercises — read class definitions and choose the most professional, accurate English description. Covers constructor patterns, inheritance, and generics.

0 / 3 completed
OOP description vocabulary
  • "This class is responsible for managing / storing / handling…"
  • "[ChildClass] extends / inherits from [ParentClass]."
  • "It overrides the [method] from the parent class."
  • "The constructor initialises the [property] to [value]."
  • "This is a generic class — it works with any type T."
1 / 3
Read this class definition. Which description is the most accurate?
class EventEmitter {
  constructor() {
    this.listeners = {};
  }
  on(event, callback) {
    if (!this.listeners[event]) this.listeners[event] = [];
    this.listeners[event].push(callback);
  }
  emit(event, ...args) {
    (this.listeners[event] || []).forEach(cb => cb(...args));
  }
  off(event, callback) {
    this.listeners[event] = (this.listeners[event] || []).filter(cb => cb !== callback);
  }
}