Skip to content
Quiz · Classes and prototypes · lesson 6 of 12

Quiz — an overridden method

What does the program print?

JavaScript
class Animal {
    speak() {
        return "Hi";
    }
}
class Dog extends Animal {
    speak() {
        return super.speak() + " Woof";
    }
}
const d = new Dog();
console.log(d.speak());

Subscribe to take the course

The course is free. Sign in with Telegram and subscribe to the channel to open every lesson.

Sign in another way