Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumJavaScriptthis in callbacks vs methodsSingle-choice MCQ1 views

A class passes its method to an event-style helper that calls it plainly. Which fix makes `this` resolve to the instance without changing the call site?

class Widget { constructor() { this.id = 7; } onClick() { return this.id; } } const w = new Widget(); const cb = w.onClick; // cb() currently fails because `this` is lost