在JavaScript中如何为JavaScript循环添加延迟在下面的代码中
snakeclass.prototype.start = function() {
while(1){
if(this.collision()){
console.log("game over");
break;
}
this.movesnake();
// delay here by 300 miliseconds
}
};
Run Code Online (Sandbox Code Playgroud)
我如何在这里使用Set Timeout功能;