> You can use
>
>
> > function waitForMillisecond(ms) { return new Promise(res => setTimeout(res, ms)); }
>
> console.time()
> console.log("Wait 1000 milliseconds");
> await waitForMillisecond(1000);
> console.log("Waited");
> console.timeEnd();
>
> > function repeatEveryMillisecond(f, ms) { return new Promise(res => setInterval(f, ms)); }
>
> repeatEveryMillisecond(() => {console.log(Math.random())}, 1000);
>
>
waitForMillisecond It’s working really well
But repeatEveryMillisecond() It didn’t work out. Still waiting for * s, then every tick run