Is it possible that they both pass the
localDocument.version > document.version
...?
No, I don't see how that would be possible. JavaScript can only run one function at a time. Any "race condition" in JavaScript deals with which function gets to run first. All synchronous function execution is atomic, so whichever function runs first will completely finish before the next one begins.
Therefore, you are guaranteed that your second check for localDocument.version > document.version
runs only after first function has completely finished.
Could this vary by JS engine implementation or is this guaranteed across different implementations?
Technically speaking, no language specification requires JavaScript to be single-threaded. Practically speaking, there does not exist any multithreaded JavaScript engine (except for engines that support sandboxed Worker-style threads, which cannot cause race conditions). Any engine that did use multithreading to handle asynchronous code would fail to handle a vast amount of existing JS code; no one would reasonably expect code written for a single-threaded JS environment to work correctly in a multithreaded environment. Such an engine would likely also have to extend the language to include locking mechanisms and atomic operations.