Question #54

Author: admin
tags: JavaScript  
// Not module
const obj1 = { m: 4 };
const obj2 = { m: 5 };

Object.setPrototypeOf(obj1, obj2);

obj1.x = () => {
  let m = 6;
  console.log(this.m);
}

obj1.x();
What will the console output be?
4
5
6
undefined
Nothing. There will be an error.
The obj1.x property contains an arrow function, and the arrow function uses the "external" this.
In this case, the value of this in the arrow function will be a global object that does not have the property m.
Rate the difficulty of the question:
easyhard