Thuta Learning
AdvancedProgrammingintermediate

Classes

Relax. We'll talk through this in plain words — no textbook voice.

TypeScript fully supports standard object-oriented features like classes, inheritance, and access modifiers (public, private).

typescript
class Animal {
  private name: string;

  constructor(name: string) {
    this.name = name;
  }

  public move(distance: number): void {
    console.log(`${this.name} moved ${distance}m.`);
  }
}

class Dog extends Animal {
  bark() {
    console.log('Woof! Woof!');
  }
}

const dog = new Dog("Buddy");
dog.bark();
dog.move(10);
You should see
Woof! Woof! Buddy moved 10m.