JavaScript-Quiz: Classes & Inheritance

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.

Mittel 10 Fragen ~6 Minuten Bestanden ab 80% Node.js 22

Modus wählen

Du spielst als Gast: Melde dich an, damit XP und Serie gespeichert werden.

Beispielfrage

Frage 1 von 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());
Lösung zeigen

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.

Darum geht es in diesem Quiz

  • 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

Häufige Fragen

Brauche ich ein Konto?

Nein. Jeder kann spielen. Mit Anmeldung werden XP, Serie, Abzeichen und Verlauf gespeichert.

Kann ich es wiederholen?

Ja. Dein Bestwert bleibt erhalten, und Fragen und Antworten werden jedes Mal neu gemischt.