cart.checkout() works, but passing cart.checkout to a button’s click listener makes it read the wrong cart ID. Explain why the two invocations behave differently. Propose a fix that also lets you remove the listener later.
The direct call uses cart as its receiver. Passing cart.checkout passes only the function, not that receiver. A DOM event listener does not call it as cart.checkout(). Register a named wrapper that calls cart.checkout(), or bind the function once and store the result. To remove it, pass the same listener reference and capture setting.
What a Strong Answer Covers
Identify which call controls this.
Preserve the receiver and keep the same function reference for removal.
Follow-up Interview Question · Why won’t calling bind again inside removeEventListener remove the original listener?