Locally modified variables will always be present in the local variable object and therefore will be "free".
In order to cover a global variable while in scope, you will need to go through the chain of visibility before reaching the global object, where it will be found in the [[global]] variable object. The cost here depends on the number of areas in the chain.
When it comes to accessing variables in different windows, now this is a completely different story.
Most modern browsers isolate each window with its own streams and with its own stack, in order to increase stability, improve garbage collection, and to avoid the need for a single stream window to crash the entire browser.
What variable access means is that variables in one window are not directly accessible to another (in another stack). So how to solve this?
To take Opera as an example, as soon as one window tries to access other Windows variables, Opera will actually pause execution, merge the two stacks and runtimes together, and then continue execution.
I think you could say it is quite expensive :)
source share