Medium'this' Binding💻 Output Question

Method chaining — return this

💡

Hint

Returning this from methods enables fluent interfaces and method chaining.

What does this output?

class Builder {
  constructor() { this.parts = []; }
  add(part) { this.parts.push(part); return this; }
  build()   { return this.parts.join(' + '); }
}
console.log(new Builder().add('A').add('B').add('C').build());

Correct Output

A + B + C

Why this output?

Explanation: add() returns this, enabling chaining. build() collects all parts.

Key Insight: Returning this from methods enables fluent interfaces and method chaining.

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 itMediumcall vs apply — same result, different syntax

Practice predicting output live →

66 output questions with instant feedback

💻 Try Output Quiz