Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: