Global Variables Are Evil
I have been known to tell people in an enterprise environment to avoid global functions and variables in JavaScript at all costs. My reasons are purely from a maintenance point of view: it’s easier to document variables attached to classes or namespaces and it’s easier to debug (because you know where to find the variable/function in question). Turns out that Douglas Crockford agrees with me in his latest post, Global Domination.
It’s so much easier to argue things successfully when you can find others to back up your point of view.
Disclaimer: Any viewpoints and opinions expressed in this article are those of Nicholas C. Zakas and do not, in any way, reflect those of my employer, my colleagues, Wrox Publishing, O'Reilly Publishing, or anyone else. I speak only for myself, not for them.