I want to separate a class implementation across different files, and I did it this way:
A.js:
export default class A {
constructor() {
this.a = 0;
}
}
B.js
import A from ...
A.prototype.foo = (n) => { this.a = n; };
But the problem is that when I call foo
, this
is undefined.
Any idea on how to fix it?