If I create a class, then I can use this
within methods to set and retrive properties. However, this
becomes undefined if I use a variable to refer to a method, as with variable b
below:
class MyClass {
methodA() {
return this;
}
}
var a = new MyClass();
var b = a.methodA;
console.log(a.methodA());
console.log(b());
Output:
MyClass {}
undefined
Why don't the log statements produce the same output?