4 ms·
In addition to the reasons mentioned, one reason is that, by design, you can only have one instance of a global variable. That might be fine today, but who kno
by magicalhippo 7y ago
In addition to the reasons mentioned, one reason is that, by design, you can only have one instance of a global variable.
That might be fine today, but who knows what tomorrows requirements might entail.
At the very least, put global variables in a context object, and pass that around. Then it's clear what is affected by and can affect the "global" state, and it's easy to create multiple context instances if you suddenly find you need to.