The community members discuss the possibility of modifying a global variable with JavaScript. One community member states that it is not possible at the moment, and another confirms that all variables are currently static. The discussion then turns to whether this feature is being considered for the roadmap, with one community member indicating that it is. Another community member provides a link to a GitHub issue (https://github.com/webstudio-is/webstudio/issues/4836) related to this feature, and a final community member notes that there is no access from arbitrary code yet, but it is a base for it.
If the value you want to store represents a state that you need to carry between pages on the site, then you can use cookies. There are many Javascript libraries that are very small, and make storing and retrieving cookies in the same session very easy.
If the value you want is only needed within the context of the current page β ie., it's OK if the browser forgets it once the visitor navigates to a different page β then you can store the value in a hidden HTML element, or in an element attribute, or even using a CSS custom variable. All of these are also changeable via Javascript.