🟦 TypeScript Classes

TypeScript classes let you create objects with properties and methods, similar to classes in other OOP languages like C# and Java.

📚 Example Code: Basic Class

Console output will appear here...
💡 You can define methods inside a class, and the this keyword refers to the instance of that class.

🔧 Class Syntax

📑 Inheritance (Extending Classes)

class Admin extends User {
  role: string;
  constructor(name: string, role: string) {
    super(name);
    this.role = role;
  }

  showRole(): string {
    return this.name + " is an " + this.role;
  }
}

const admin1 = new Admin("Jamie", "Administrator");
console.log(admin1.showRole());
  
⚡ Use extends to create a child class, and call the parent constructor with super().