I have this class:
class A {
name = 'foo';
displayName() {
console.log(this.name);
}
}
And I'd like to call the displayName
method within a callback after the instantiation. I've done this:
const a = new A();
someCode('blabla', a.displayName.bind(a));
But I don't like this. Is there a more elegant way to do it?