How to make a forever loop in JS not freeze
check setTimeout() : https://developer.mozilla.org/en-US/docs/Web/API/setTimeout
Something like that to loop indefinitely without blocking the main thread (you should probably design a way to break the loop at some point) :
function doSomeStuff() {
  // do some stuff…
  setTimeout(() => {
    doSomeStuff();
  }, 1000);
}


I'm working on a block based programming language based of of Google's Blockly. I need to make a block that loops the contents forever, for making games.
I tried a while (true) loop but it froze. Is there any way to make a forever loop that won't freeze and will let other scripts run?
Thanks!
