у объекта есть метод:
move(){
setInterval(function(){
if(this.direction==0){
this.moveRight;
console.log("try move right");
}
else
if(this.direction==1){
this.moveLeft;
console.log("try move left");
}
else
if(this.direction==2){
this.moveUp;
console.log("try move up");
}
else
if(this.direction==3){
this.moveDown;
console.log("try move down");
}
else{
console.log("i am standing...");
}
return this;
},1000);
}
как можно заставить выполняться методы this.moveRight, this.moveLeft, this.moveUp, this.moveDown?
на данный момент контекст this - это Window, а методов - undefined.
this.moveRight->this.moveRight()– Austral1a Sep 13 '21 at 18:10