1: Under global scope the This object points to the Window object
For example:
The results are as follows:
2: Under Function scope
In non-strict mode: The point of this is still the Window object
For example:
The results are as follows:
In strict mode:
The point of this is undefined
For example:
The results are as follows:
So inside the function, in strict mode, this point or value is undefined
3: Inside the object
The point of this is the current object
For example:
The results are as follows:
There is a classic question about this point:
Please see:
In non-strict mode, the results are as follows:
If in strict mode, for example:
The results are as follows:
So how do you get the function fn to use the current obj object, the analogy is to output the value of name in FN, how to write?
The first method:
The second solution: (using the arrow function can be very good solution)
A simple summary of the question about this point in JS