So, I read Javascript - The Good Parts , and one thing Crockford points out is the weakness of using global variables in Javascript so that if your product extends somehow and relies on a "global" variable, it may be unintentionally set.
This is all good and wonderful, and I understand the pros and cons of protecting variables in other ways, such as closing. However, I did some thoughts and wrapped the code in a function like this:
(function () { var x = 'meh'; })(); (function () { alert(typeof x);
gives it a variable scope, which thereby prevents cross-contamination of variables. I am not sure if there is a glaring flaw in this approach, although I wondered if the community has any data, or if I just overdo it and ignore the main thing.
javascript
A wizard did it
source share