Medium'this' Binding💻 Output Question

call vs apply — same result, different syntax

💡

Hint

call(thisArg, ...args) vs apply(thisArg, [args]) — same result, different argument style.

What does this output?

function greet(greeting) {
  return greeting + ', ' + this.name + '!';
}
const user = { name: 'Bob' };
console.log(greet.call(user, 'Hello'));
console.log(greet.apply(user, ['Hi']));

Correct Output

Hello, Bob!
Hi, Bob!

Why this output?

Explanation: call and apply both set this explicitly. call takes arguments individually; apply takes an array.

Key Insight: call(thisArg, ...args) vs apply(thisArg, [args]) — same result, different argument style.

More 'this' Binding Output Questions

EasyMethod call — this is the calling objectEasyArrow function has no own this — inherits lexicallyMediumbind permanently fixes this — call cannot override itMediumArrow callback inside method preserves this

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz