"This" for arrow function

·

1 min read

this of arrow function is defined by nearest/parent function

const obj = {
  msg: 'hello',
  // that -> Window
  b: function () {
     console.log(this)
  },
  a: () => {
    return this.msg;  // How to determine this? imagine placing an imaginary "that" in parent scope, what would "that" be?
  },
};