Wrap your custom JavaScript code in Closure functions

I finally figured out how to use closures properly in JavaScript. This came as a result of my needing to make sure globals I was defining in different script files weren’t conflicting with same named globals in other files. My solution was rather simple, just wrap existing chunks of code in their own function wrapper: Original Code: Note that the variables globalVar and anotherGlobal are truly GLOBAL and any other javascript file(s) with the same variables declared will cause major issues for our code (or vise versa). [Read More]