I am cofused about the behaviour of arrow functions. Please look at the following example:
class Test {
foo2 = () => {
console.log(this)
}
}
let t1 = new Test
let Test2 = {
foo2: () => {
console.log(this)
}
}
t1.foo2()
Test2.foo2()
Test2.foo2()
returns an empty object which makes sense as arrow functions doesn't have there own "this", but why is t1.foo2()
logging t1 object? Aren't both the situations same ?