Answer the question
In order to leave comments, you need to log in
How to correctly call a class method in the SetInterval function?
class Server{
constructor(){
this. arrayGame = []
}
Update(){
for (let i =0; i < this.arrayGame.length; ++i){
что то происходит
}
}
}
Answer the question
In order to leave comments, you need to log in
I don't know the syntax of ES6 classes, but it seems like this
class Server{
constructor(){
this.arrayGame = []
var self = this;
setInterval(function () { self.Update() }, 1000);
}
Update(){
for (let i =0; i < this.arrayGame.length; ++i){
что то происходит
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question