In the section "Namespacing Patterns", the code given in #5. Immediately-invoked Function Expressions (IIFE)s does not quite work.
The first long part given works, but the second part that is supposed to extend the namespace does not work.
I tested this by copying both sections to a jsFiddle and changing the console.log calls to alert calls. The call to sayGoodbye is executed, but the value of foo and bar are undefined and the call to speak throws a ReferenceError. If I put the namespace name in front of speak, it then throws a TypeError, saying it is not a function.
In the section "Namespacing Patterns", the code given in #5. Immediately-invoked Function Expressions (IIFE)s does not quite work. The first long part given works, but the second part that is supposed to extend the namespace does not work.
I tested this by copying both sections to a jsFiddle and changing the console.log calls to alert calls. The call to sayGoodbye is executed, but the value of foo and bar are undefined and the call to speak throws a ReferenceError. If I put the namespace name in front of speak, it then throws a TypeError, saying it is not a function.