Skip to content

TypeScript code snippet – How to extend ts class?

class Animal {
  move(distanceInMeters: number = 0) {
    console.log(`Animal moved ${distanceInMeters}m.`);

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

const dog = new Dog();
See also  How to edit a specific line in text file in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.