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.

Was this helpful? If you found this post helpful, I would very much appreciate your support. Donations of any amount gratefully accepted.