Skip to content

Instantly share code, notes, and snippets.

@lizlongnc
Last active August 29, 2015 14:07
Show Gist options
  • Save lizlongnc/07102199a524cfe091d1 to your computer and use it in GitHub Desktop.
Save lizlongnc/07102199a524cfe091d1 to your computer and use it in GitHub Desktop.
JS this
If you using a function with an outside object, use this.
The this pseudo parameters contains a reference to the object of invocation.
this allows a method to know what object it is concerned with.
this allows a single function object to service many objects.
this is key to prototypal inheritance.
allows a single function to work on many objects
the way the function knows which object it is working on is by the this binding
this is a bonus parameter. Its value depends on the calling form.
this gives methods access to their objects
this is bound at invocation time.
Invocation form this
function the global object undefined
method the object
constructor the new object
apply argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment