JavaScript Classes & Inheritance Quiz

This JavaScript quiz covers the class syntax used in most modern code. You will predict output for subclasses, super calls, overridden methods and class fields, and spot the classic errors with this.

Medium 10 questions ~6 minutes Pass at 80% Node.js 22

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

What does this print?

class Animal {
  constructor(name) { this.name = name; }
  speak() { return `${this.name} makes a sound`; }
}
class Dog extends Animal {
  speak() { return `${super.speak()}, woof`; }
}
console.log(new Dog("Rex").speak());
Show the answer

A. Rex makes a sound, woof Dog has no constructor, so the default one passes "Rex" to Animal's constructor. super.speak() calls the parent method with the same this, then Dog appends its own text.

What this quiz covers

  • Constructors, methods and class fields
  • extends and calling super() and super.method()
  • Method overriding and dynamic this
  • Losing this when a method is passed around
  • Private #fields

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.