🔴 Hard'this' Binding💻 Output Question

Prototype chain property lookup

💡

Hint

Property lookup walks the prototype chain. "this" inside prototype methods still refers to the calling object — so this.type finds the FIRST type in the chain starting from grandchild.

What does this output?

const base = { type: 'base', describe() { return this.type; } };
const child = Object.create(base);
child.type = 'child';
const grandchild = Object.create(child);

console.log(grandchild.type);
console.log(grandchild.describe());
console.log(grandchild.hasOwnProperty('type'));
console.log(child.hasOwnProperty('type'));
console.log(grandchild.__proto__ === child);

Correct Output

child
child
false
true
true

Why this output?

Explanation: grandchild has no own "type" — walks chain → finds child.type = "child". describe() is found on base; this = grandchild, so this.type = "child" (walks chain). grandchild has no own "type". child does have own "type". __proto__ === child is true.

Key Insight: Property lookup walks the prototype chain. "this" inside prototype methods still refers to the calling object — so this.type finds the FIRST type in the chain starting from grandchild.

More 'this' Binding Output Questions

🟡 MediumMethod extracted from object→🟡 MediumArrow function this→🔴 Hardthis in nested function→🔴 Hardbind creates new function→

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz