* Disclaimer: I'm not saying this is a good idea - as a matter of fact I'll explicitly say it is not - so take this question by way of trying to understand what exactly the event-loop means for coding style.
My rudimentary understanding of the javascript-has-no-threads mantra is that the runtime treats all of javascript as short "blocks of code" which are scheduled executed one after the other without ever shifting away from a block during execution. A block of code (I don't know the real terminology) in this case is basically code that runs as a result of an event handler being triggered.
If my understanding is correct that would mean that it is technically 100% safe to use global variables if your use of them does not span more than one "block of code".
So for example if I have a single global object window.workspace
I could have my event handlers and any code that flows from there - rather than storing temporary variables in closures - store them all in window.workspace
. As long as I don't assume that workspace to retain any state in between calls to event handlers (even the same one), this should be perfectly safe.
Is this accurate (though, once again, not advised)