When I call a method of an es6 class from a callback I can no longer refer to this
as my object:
class store{
constructor(){
this.value = 10;
};
printValue(self){
console.log(this);
console.log(self);//the value that I want print
};
};
class undefinedClass{
constructor(store){
this.store = store;
};
storeQuery(){
let ff = this.store.printValue;
setTimeout(ff, 300, this.store);
};
};
let i = new store();
let b = new undefinedClass(i);
b.storeQuery();
When I call b.storeQuery() tha value that I want print is the second one. Is there a more elegant way for do that?