|
|
|
|
|
by bramen
3140 days ago
|
|
There's already a proposal for field declarations, where you can do the following: class Foo {
bar = () => {
console.log(this);
}
}
This basically puts `this.bar = () => console.log(this)` in the constructor, and since it's an arrow function it captures the correct context.See https://github.com/tc39/proposal-class-fields. |
|