I cannot figure out why the following does not work:
var foo = { f1: () => 5, f2: this.f1() }
I get this error:
TypeError: this.f1 is not a function
It seems that this
refers to the global scope instead of foo
. Everything works fine with the following:
var foo = { f1: () => 5, f2() { return this.f1 } }
Is there a way to refer to f1
without wrapping it in a new function?