According to your experience, you can suggest some method of being able to maintain an execution loop to keep the logic of an application of a videogame in javascript, I am doing the part of the render with canvas to draw.
I'm currently using something similar to this:
function init() {
game = new Game();
setInterval(function() {
game.loop();
},50);
}
function Game(){
this.loop = function(){
//Lógica del juego
}
}
I consider that it is not a practical way to maintain the execution since apparently it is expensive to do it this way.