Quantcast
Channel: Javascript: namespacing - Stack Overflow
Browsing all 4 articles
Browse latest View live

Answer by Tim Büthe for Javascript: namespacing

I think your example is just fine and this whole question is mostly about taste. However, I wourld write it like this: var NAMESPACE = { publicVar1: '', publicFunction1: (function(){ var privateVar1 =...

View Article



Answer by Justin Van Horne for Javascript: namespacing

Actually, it is all about semantics. If you are breaking your code apart multiple files and plan on utilizing a general namespace then doing something like this is a little bit easier: The reason why I...

View Article

Answer by Anatoliy for Javascript: namespacing

This is good, but better to declare private variables as local variables in namespace, instead of using one object priv. Advantages: less code, packer may shrink variable names. Try to pack your code...

View Article

Javascript: namespacing

I'm currently using the following pattern to create namespaces and singleton objects in Javascript: var Namespace = function () { var priv = { privateVar1: '', privateVar2: '', privateFunction1:...

View Article
Browsing all 4 articles
Browse latest View live




Latest Images