I agree with Vee41.
As a general practice I use myself.
* Each event sheet get's a Group labels after the event sheet.
* any variables that I need in the event sheet get put into the group
* all groups in the event sheet get put into the head group
* any access to the variable from an external event-sheet will often use a Function.Call("eventgroup.get[VAR]").
it's really really rare when I find the use of a true GLOBAL required. When I do it will often be a value like "DEBUG_MODE" and similar.
otherwise I think Darklinki does a good job of explaining the why. However to expand on that.
C2 uses a self closure. This enforces that it's impossible for the same var name at the room to conflict with any browser's own variable decleration. However the rest is right.
mindandcode.com/quick-thoughts/why-global-variables-have-slow-performance-in-javascript
unlike many other languages that use a model of variable to memory address; which is direct. All variables in JS are stored in a table. JS actually traverses the table every time you need to access the variable. As a general rule of thumb for JS. If you need to use a variable data more than twice in any function. Then store the data locally in the function. then use it.
ie
A = 24734
function scope{
print A + A * A / A
}
is bad do the fact A is used outside the scope and JS needs to traverse the data table where A is stored.
where as
function scope{
var b = A;
print b + b * b / b
}
is better because JS won't be traversing the variable scope table for very long. As b is the only variable and ensures quicker execution.
honestly though the example is so simple it wouldn't matter. But it adds up in heavier math computation needing to be done much mroe often... like graphics :D