What does 'this' return in JavaScript?
At the top level 'this' is usually going to refer to the 'Global Object', which in the browser is the 'Window'.
But there's a caveat to this, and that's that if you're in a module, this is simply going to be undefined.
In a function, it depends on how that function is actually invoked.
So typically, this is going to be the object that calls the function.
So if we have one function and we put that function on two objects, this is going to refer to whichever object called the function.
But if the function is called from the top level, well, then this is simply going to be the global object or the window.
If that top level function is also in strict mode, it's going to simply be undefined.
And there's also a caveat to that caveat.
And that's arrow functions.
Arrow functions do not create their own this binding and instead use the this value of the enclosing environment in a class.
This is almost always going to refer to the object being constructed.
But there is, of course, a caveat to this, and that's static properties.
Static properties are not specific to any instance of the class, so instead, this is going to refer to the class itself.