JavaScript Anonymous Closures


So what if we have a namespace with public properties that we want to make private?

If we want things to be accessible only to the module, we can use an anonymous closure.

Any local variables will be “closed up” in the namespace and made “private”.

We can put everything into an immediately invoked function, and then return an object with the “public” properties.