What I understand is that arrow functions don't rebind this
, so why does it refer to different objects depending on how it's invoked?
const foo = {
speak() {
(() => {
console.log(this);
})();
}
};
foo.speak(); // Logs foo
const speak = foo.speak;
speak(); // Logs the global object
Thank you for your time!