What do call, apply and bind do?
Take a moment.
Say your answer out loud or write it down first — retrieval is what makes it stick. Reveal when you're ready.
Short answer
All three control what this refers to when invoking functions. call invokes immediately with listed arguments, apply invokes immediately with an array of arguments, bind returns a new permanently-bound function.
Detailed explanation
Every regular function's this depends on its call site; these methods override that. fn.call(context, a, b) runs fn right away with this = context and arguments a, b. fn.apply(context, [a, b]) does the same but takes arguments as an array — historically useful for spreading arrays before the spread operator existed. fn.bind(context) doesn't run anything; it returns a copy of the function whose this is locked to context (partial application of leading args is possible too). Bound functions ignore later attempts to re-bind. Typical uses: borrowing methods (e.g., calling Array.prototype.slice on array-like objects), event handler binding in class-based code, and ensuring callbacks keep their intended context. Note arrows ignore all three for this, since theirs is lexical.
Example
function greet(greeting, punct) {
return `${greeting}, ${this.name}${punct}`;
}
const user = { name: 'Ada' };
greet.call(user, 'Hello', '!'); // 'Hello, Ada!'
greet.apply(user, ['Hi', '?']); // 'Hi, Ada?'
const bound = greet.bind(user, 'Hey');
bound('.'); // 'Hey, Ada.'Interview tip
Give the one-line mnemonic — call = comma-separated, apply = array, bind = later — then show one example each. Fast, complete, memorable.
Common mistakes
- Confusing apply's array-of-args signature with call's spread args.
- Forgetting bind returns a new function rather than invoking.