【发布时间】:2015-06-16 12:58:03
【问题描述】:
我很惊讶这不起作用。 (我正在运行带有--harmony_arrow_functions 标志的iojs 2.3.0。)
class Foo {
constructor() { this.foo = "foo"; }
sayHi() { return (() => this.foo)(); }
}
f = new Foo();
f.sayHi // Cannot read property 'foo' of undefined.
我本来希望箭头函数为this 选择正确的值。我错过了什么吗?
【问题讨论】:
标签: node.js ecmascript-6