Data accessed from JavaScript APIs must not be modified while a JavaScript event loop is running.
A JavaScript Web API is generally a wrapper around a feature implemented in a lower-level language, such as C++ or Rust. Unlike those languages, JavaScript guarantees that once a piece of code begins executing, it will continue executing until it has completed.
Because of that, JavaScript developers take for granted that the data available to a function won’t change (unless that function changes that data itself).
So if a JavaScript Web API exposes some piece of data, such as an object property, the user agent must not update that data while a JavaScript task is running. Instead, if the underlying data changes, queue a task to modify the exposed version of the data.
For example: If a JavaScript task is has accessed the
navigator.onLine
property, and browser's online status changes, the property will not be updated until the next task.