MohitDecodes
Back to blogsJavaScript

How 'this', call, apply, and bind Actually Work in JavaScript

October 26, 2026 · 7 min read

Confusion around `this` is one of the longest-running sources of JavaScript interview bugs. Unlike lexical variables, a regular function's `this` depends on *how the function is called*, not where it was declared.

The four rules in priority order

  • 1. `new` binding: `new User()` creates a fresh object and binds `this` to it.
  • 2. Explicit binding: `fn.call(obj, a, b)`, `fn.apply(obj, [a, b])`, or `fn.bind(obj)` sets `this` to `obj`.
  • 3. Implicit binding: `user.greet()` binds `this` to whatever sits left of the dot (`user`).
  • 4. Default binding: standalone `greet()` gives `undefined` in strict mode (or global object in sloppy mode).

Why arrow functions behave differently

Arrow functions don't have their own `this` at all — they inherit `this` lexically from their surrounding scope. That's why arrow callbacks inside methods keep the method's `this`, while arrow functions used directly as object methods usually don't do what you expect.

const team = {
  name: "Frontend",
  members: ["A", "B"],
  print() {
    this.members.forEach((m) => console.log(`${m} in ${this.name}`));
  },
};

Further reading