4 ms·
How to structure your JavaScript code
- pmjordan 18y agoNothing vastly new here (especially if you've watched Douglas Crockford's videos) although I must admit I quite like the local var global = this; concept for when you're creating more than one element in the global namespace/object. The reason you wouldn't use window is of course that your code will port to non-browser platforms, and you don't use unqualified names because they look like a mistake (e.g. you left the 'var' off)
- cdr 18y agoThis is pure blogspam; the real link is http://peter.michaux.ca/article/9081 http://peter.michaux.ca/article/9081
- DanHulton 18y agoMan, I'll have to write up how I structure javascript at some point. I prefer using objects for namespaces, while he's got good points about why those can cause problems, there's well-known workarounds for what he points out.