Can the value of a JS variable defined in a script be modified in that same scope upon the next reload without modifying that script?
As far as I know, no.
If you want something that can be changed between reloads but with the last stored value also persisted between page reloads, you can use cookies or localstorage.
Okay technically speaking, you can make reality whatever you want by editing things in your browser's developer tools (if the developer tools for your browser support it): put a breakpoint in a place in that variable's scope, then when the breakpoint is hit, use whatever functionality your browser's developer tools provide to edit the value of that variable. Some browsers are quite flexible with this and will even allow you to assign new values to variables declared using const
. That change that you make will only last for that browsing session, and upon page reload, that change will be forgotten. But I kind of doubt this is what you're looking for. See also https://stackoverflow.com/a/73441795/11107541.