JavaScript-Quiz: Prototypes

This JavaScript quiz looks under the hood of objects, at the prototype chain that classes are built on. You will predict output for Object.create, shadowed properties, instanceof and for...in, and pick the right way to link constructor functions.

Schwer 10 Fragen ~8 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?

const animal = {
  sound: "...",
  speak() { return this.sound; },
};
const dog = Object.create(animal);
dog.sound = "woof";
console.log(dog.speak(), animal.speak());
Lösung zeigen

B. woof ... dog has no speak of its own, so it is found on animal, but this is still dog, the object before the dot. dog.sound is its own property and shadows the one on animal.

Darum geht es in diesem Quiz

  • How property lookup walks the prototype chain
  • Reading vs writing an inherited property
  • prototype vs Object.getPrototypeOf()
  • in, Object.hasOwn() and for...in with inherited keys
  • Objects with no prototype from Object.create(null)

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.