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.

Understanding JavaScript Promises E-book Cover

Demystify JavaScript promises with the e-book that explains not just concepts, but also real-world uses of promises.

Download the Free E-book!

The community edition of Understanding JavaScript Promises is a free download that arrives in minutes.