πŸ”΄ Hard'this' BindingπŸ’» Output Question

bind creates new function

πŸ’‘

Hint

A bound function's this is permanent. call/apply cannot override it.

What does this output?

function greet() {
  console.log(this.name);
}

const alice = { name: 'Alice' };
const bob = { name: 'Bob' };

const greetAlice = greet.bind(alice);
greetAlice.call(bob);

Correct Output

Alice

Why this output?

Explanation: bind() creates a permanently bound function β€” this cannot be overridden by call(), apply(), or even new (with some exceptions). The bound this always wins.

Key Insight: A bound function's this is permanent. call/apply cannot override it.

More 'this' Binding Output Questions

🟑 MediumMethod extracted from objectβ†’πŸŸ‘ MediumArrow function thisβ†’πŸ”΄ Hardthis in nested functionβ†’πŸŸ‘ MediumsetTimeout this lossβ†’

Practice predicting output live β†’

66 output questions with instant feedback

πŸ’» Try Output Quiz