The module consists of lines 1 – 31, you can see that all items defined in the module are locally scoped to the module. Lines 25 – 30 define what will be publicly accessible outside of the module. Note that line 29 defines a different public name in comparison to its internal name. Also note that objects inside of the module can access each other. Line 16 is calling the private function on line 11. Trying to call privateFunction1 from outside the module would not be possible.
Also in this example I am showing some common things I like to do. For example lines 2 – 5 define an object for selectors. I make this selector object public incase the page that consumes this module needs to change the values. Everywhere else in the module I call the selectors from the selector object. This way if I need to change a value either manually in this script or dynamically from the page it is only done in one place. Note lines 7 – 9 define the same thing although this time its urls. Since I do a lot of my work in MVC I assign the url values on the consuming page using the url helpers.
In another post I will go over the organization and utilization of this pattern in an MVC 3 application.