this : nested functions
JavaScript
class Service {
constructor(){
this.numbers = [1,2,3];
this.token = "token";
}
doSomething(){
setTimeout(function doAnotherThing(){
this.numbers.forEach(function log(number){
//Cannot read property 'forEach' of undefined
console.log(number);
console.log(this.token);
});
}, 100);
}
}
let service = new Service();
service.doSomething();