JS: Function Call, Apply, Bind

By Xah Lee. Date: . Last updated: .

In JavaScript, any function, when called, has a associated value called “this binding”.

In function definition, the value of “this binding” is represented by the keyword this.

[see JS: “this” Binding]

When a function f is called in the form x.f(…), the value of “this binding” is the object x.

You can use methods {call, apply, bind} to pass any object to be “this binding”.

The methods {call, apply, bind} are properties of the object Function.prototype. ALL JavaScript functions are decedents of Function.prototype. [see JS: Prototype and Inheritance]

Function.prototype.call

[see JS: Function.prototype.call]

Function.prototype.apply

The function “apply” is the similar to “call”, but the second argument is a array. The elements of the array is passed to the function as separate arguments.

[see JS: Function.prototype.apply]

For ES2015, use Reflect.apply instead.

[see JS: Reflect.apply]

Function.prototype.bind

[see JS: Function.prototype.bind]

Function Topic

  1. JS: Define Function
  2. JS: Arrow Function
  3. JS: Function Parameters
  4. JS: var/function Order
  5. JS: var Name Scope
  6. JS: Function Declaration vs Function Expression
  7. JS: Closure
  8. JS: Functional Programing
  9. JS: Function Call, Apply, Bind
  10. JS: Function Argument Default Value
  11. JS: Function Rest Parameters
  12. JS: Function Argument Destructure

  1. JS: Function Object
  2. JS: Function.prototype
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon