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.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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:
Then you have no idea what would have run before your function started.