this is a special keyword.
When we use it in a piece of code,
it refers to the ‘object’ that is calling the code.
In the example given below,
we are using
this inside the method
person object contains the
this refers to the
The value of
this also depends
on where we are using it.
If we use
thisin the global scope,
thisrefers to the global object.
When we use it inside a function in the global scope,
thisrefers to the global object. However, if strict mode is being used, then
When we use it inside a function of a class,
thisrefers to the instance of the class calling that function.
When we use it inside the method of an object,
thisrefers to that object.