Skip to content

Instantly share code, notes, and snippets.

@11ma
Created July 10, 2020 11:42
Show Gist options
  • Save 11ma/82eedf0a2939ea8b9be924955fd616f6 to your computer and use it in GitHub Desktop.
Save 11ma/82eedf0a2939ea8b9be924955fd616f6 to your computer and use it in GitHub Desktop.
call, apply, bind
call, apply, bind are methods functions have access to.
The bind() method makes a copy of the function attached to it. Whatever object you pass to it is what the "this" points to by reference.
The call() takes the object "this" will point to as a parameter. Unlike bind(), call() doesn't make a copy of the function, it executes the function.
The apply() also takes the object "this" will point to as a parameter, smiliar to the call, but it takes the rest of its values as an array.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment