Javascript Fundamentals

Bind, Call, and Apply in JS

Call:

  • Set the ‘this’ variable to another object.
  • Borrow a method from another object.

Apply:

  • The apply() method is used to write methods, which can be used on different objects. It is different from the function call() because it takes arguments as an array.

Bind:

  • Similar to call.
  • Lets us set the ‘this’ variable explicitly.
  • “Bind doesn’t immediately call the function, but generates a copy of the function so that we can store it somewhere”
  • Bind method returns a function.