addyosmani / essential-js-design-patterns

Repo for my 'Learning JavaScript Design Patterns' book
http://addyosmani.com/resources/essentialjsdesignpatterns/book/
4.82k stars 792 forks source link

code example for Namespacing Pattern IIFE does not work #140

Closed joyously closed 10 years ago

joyously commented 10 years ago

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.

addyosmani commented 10 years ago

Confirmed bug. Thanks for filing this! I'll get it fixed up.