thisis used inside a function (let’s say function A) and it contains the value of the object that invokes function A.
thisis not assigned a value until an object invokes the function where this is defined.
- the object that invokes the
thisfunction is in context, and we can change the context by invoking the
thisfunction with another object (such as using
apply()method); then this new object is in context.
- If we really want this.data to refer to the data property on the specific object, we can use the Bind (), Apply (), or Call () method to specifically set the value of
- closures cannot access the outer function’s
thisvariable by using the
thiskeyword because the
thisvariable is accessible only by the function itself, not by inner functions.