I have class like this
class Game {
constructor(player1, player2, gameId) {
this.Clockk = {
totalSeconds: timeForAnswer,
nowSeconds: timeForAnswer,
start: function () {
var self = this;
this.interval = setInterval(function () {
self.nowSeconds -= 1;
if (self.nowSeconds == 0) {
here I want to call "answered" function
}
},
reset: function(){
this.nowSeconds = this.totalSeconds;
},
};
answered(player) {
console.log(player);
}
};
I want to call function of Game
class from this.Clockk
variable. this
keyword inside a variable is this.Clockk
itself, how can I get parrent class itself?
Aucun commentaire:
Enregistrer un commentaire