🟡 Medium'this' Binding💻 Output Question

Method extracted from object

💡

Hint

this is determined by HOW the function is called, not where it was defined.

What does this output?

const obj = {
  name: 'Alice',
  greet() {
    console.log(this.name);
  }
};

const greet = obj.greet;
greet();

Correct Output

undefined

Why this output?

Explanation: When greet is extracted from the object and called as a plain function, this is undefined (strict mode) or the global object (non-strict). Either way, this.name is undefined.

Key Insight: this is determined by HOW the function is called, not where it was defined.

More 'this' Binding Output Questions

🟡 MediumArrow function this→🔴 Hardthis in nested function→🔴 Hardbind creates new function→🟡 MediumsetTimeout this loss→

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz