Skip to the solution
MediumFrontend6 min read

What is the difference between call, apply, and bind?

801 views

The problem

Question presented to candidate: "What's the actual difference between call, apply, and bind β€” not just how their arguments are formatted, but what each one actually DOES to the function?"

What a strong answer should cover:

  • πŸ“Œ Interview term: fn.call(thisArg, arg1, arg2, ...) β€” invokes fn immediately, with this set to thisArg, passing the remaining arguments individually.
  • πŸ“Œ Interview term: fn.apply(thisArg, [arg1, arg2, ...]) β€” invokes fn immediately, identical to call, except the arguments are passed as a single array.
  • πŸ“Œ Interview term: fn.bind(thisArg, arg1, ...) β€” does not invoke fn at all; it returns a new function with this permanently locked to thisArg (and optionally some leading arguments pre-filled), to be called later.
  • πŸ“Œ Interview term: the real, direct distinguishing proof β€” verified directly: calling .call()/.apply() genuinely invoked the function immediately (a tracking flag flipped to true synchronously), while calling .bind() genuinely left that same flag false until the returned bound function was separately, explicitly called.
  • A precise answer names that once a function is bound, its this genuinely cannot be overridden by a later .call(), .apply(), or even another .bind() β€” verified directly, the original bound this stayed in place through both override attempts β€” and that arrow functions ignore all three methods' this argument entirely, since arrow functions have no this of their own to rebind.

Clarifying questions expected:

  • None β€” this is a definitional/comparison question; correctly distinguishing "invokes immediately" (call/apply) from "returns a new function for later" (bind) is the strong signal, beyond the argument-formatting difference most candidates already know.

Code / implementation expected: Yes β€” demonstrating the immediate-invocation vs. deferred-invocation distinction directly (not just the argument format) is the most convincing proof of real understanding.

  • call-apply-bind

Try it yourself

Sketch your approach before you read the solution. That is what the interview tests.

Stuck? Get a hint.

A short nudge toward the approach. It will not give the answer away.

Solution

The solution is hidden so you can try first

6 min read Β· 8 sections

Run the code

Edit the code and run it here. Each console line with an expected value becomes a test.

JavaScriptReal proof: call/apply invoke immediately, bind returns a new function, and a bound this cannot be overridden

Discussion

Other approaches, follow-ups and how it went in real interviews.

Sign in to join the discussion.

No comments yet. Share how you would answer it.

Question 65 of 165 in JavaScript

Keep your momentum going.

Mark this question solved to track your progress, then take the next one while it is fresh.

Up nextMedium

How do you handle asynchronous operations in JavaScript?

Continue