Quiz de JavaScript: 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.

Difícil 10 perguntas ~8 minutos Aprovação com 80% Node.js 22

Escolha um modo

Jogando como visitante: entre para guardar seu XP e sua sequência.

Pergunta de exemplo

Pergunta 1 de 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());
Mostrar a resposta

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.

O que este quiz cobre

  • 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)

Perguntas frequentes

Preciso de uma conta?

Não. Qualquer pessoa pode jogar. Entre para guardar seu XP, sequência, badges e histórico.

Posso refazer?

Pode. Sua melhor nota fica salva, e as perguntas e respostas são embaralhadas a cada vez.