You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • but isn't this actually a race condition?

    It's actually fine in JavaScript. JS is itself normally only single-threaded, so if you're inside a function, no other JS is going to be able to run and mess things up for you.

    It's just when you first start your function. For example if you do:

    setInterval(function() {
     // here
    }, 1000);
    

    Then you have no idea what would have run before your function started.

About

Avatar for Gordon @Gordon started