cf.completefrontend

Predict the outputMedium

What does a nested function inside a method see as this, compared with a nested arrow?

What does this log?
var x = "global";
 
const obj = {
  x: "obj",
  outer() {
    function inner() {
      return this.x;
    }
    const arrow = () => this.x;
    return [inner(), arrow()];
  },
};
 
console.log(obj.outer());

The answer

Work out every line it logs, in order. Then check.

Checking your sign-in…