Квиз по 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.

Сложный 10 вопроса ~8 минуты Проходной балл: 80% Node.js 22

Выберите режим

Вы играете как гость: войдите, чтобы сохранить XP и серию.

Пример вопроса

Вопрос 1 из 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());
Показать ответ

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.

Что проверяет этот квиз

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

Частые вопросы

Нужен ли аккаунт?

Нет. Играть может любой. Войдите, чтобы сохранять XP, серию, значки и историю.

Можно пройти ещё раз?

Да. Лучший результат сохраняется, а вопросы и ответы каждый раз перемешиваются.