So I'm currently writing an Electron application (info here), and I had a need to stop my JS thread for just 250ms (0.25s). In Python, I simply would have:
time.sleep(.25)
But I'm not used to writing to JS, so I thought linearly; I have to stop and wait, using a single command. However, that's not the case here. As it turns out, there are three options for those of you who found this thread:
var run = setTimeout(function1, 250);var run = setInterval(function1, 250);var waitTill = new Date(new Date().getTime() + seconds * 1000);while(waitTill > new Date()) {}Comment/upvote if you found this tidbit useful. I'll start posting more regularly now that school is out, so expect some in-depth, interesting articles soon.