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.

कठिन 10 सवाल ~8 मिनट पास होने के लिए 80% Node.js 22

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 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, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।