Everywhere I read people say "this" inside a function is the global object, "this" outside a function is the module.exports, and "this" inside an arrow function is an empty object.
But it's not exactly like that inside an instanced function, is it? For example:
function Test() {
this.arrowThis = () => {
console.log(this)
}
console.log(this)
}
const test = new Test
console.log(test.arrowThis())
When the function is being instanced the "this" output is the function itself and when the .arrowThis() arrow function is being called the output are 2 values, one value is the instanced function and the other is an empty object.
I am having dificulties to understand the logic behind it. Could anyone here try to explain exactly what is the behavior of "this" in this case?