MediumPrototypes & Inheritance💻 Output Question

Object.create sets prototype directly

💡

Hint

Object.create(proto) is the direct way to set up prototype inheritance without classes.

What does this output?

const proto = {
  greet() { return 'Hello, ' + this.name; }
};
const obj = Object.create(proto);
obj.name = 'Alice';
console.log(obj.greet());
console.log(Object.getPrototypeOf(obj) === proto);

Correct Output

Hello, Alice
true

Why this output?

Explanation: Object.create(proto) creates a new object with proto as its prototype. greet() is found via chain.

Key Insight: Object.create(proto) is the direct way to set up prototype inheritance without classes.

More Prototypes & Inheritance Output Questions

Easyinstanceof traverses the prototype chainMediumhasOwnProperty vs in operatorMediumClass method override and instanceofMediumsuper calls the parent method

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz