See more
We learned the risks of global variables years ago. Thankfully, there are many ways to encapsulate JavaScript these days: