Why in both examples an empty object is being printed out? In the first example, should this be equal to the global environment? Also, in the second example, I've used an arrow function to bind this to obj2 object, so I expected x() to return the obj2 object, but got an empty object instead? Can someone please explain what's going on here.
let obj1 = {
name: "object1",
method: function(a) {
console.log(a)
}
}
obj1.method(this)
// ---------------------
let obj2 = {
name: "object2",
method: () => {
console.log(this)
}
}
let x = obj2.method;
x()