Learning JavaScript Design Patterns

Errata for Learning JavaScript Design Patterns

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 1
1

There have been a number of minor corrections made to the open-source version of the book. The changelog for these changes can be found here https://github.com/addyosmani/essential-js-design-patterns/commits/1.5.2, but we only need to pay attention to those made since October 27th. We need to apply the change made in each of the commits to the production version of the book. In most cases a simple search will locate the sentence, word, phrase or piece of code that was updated. e.g In https://github.com/addyosmani/essential-js-design-patterns/commit/3b3891410f6e1fe038f3357bbc2eb0a27bfe70e9 we can see that there was an indentation fix and a fix to the name of a variable.

Addy Osmani
O'Reilly Author 
Dec 11, 2012  Mar 01, 2013
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 1
Numerous

There have been a number of fixes made to the book since the last O'Reilly refresh. These changes can be found here in the changelog: https://github.com/addyosmani/essential-js-design-patterns/commits/1.5.2. Clicking any change will show the old text as well as the replacement text. For example: Correction to IIFE code samples: https://github.com/addyosmani/essential-js-design-patterns/commit/b92a7a086f25237c746790fbd76532dd91b8dde0 Missing arguments in one of the code samples: https://github.com/addyosmani/essential-js-design-patterns/commit/f5039856a7f9d2b4bf6c5a34f61fa3df4b17ccc5 Correction for observer code sample: https://github.com/addyosmani/essential-js-design-patterns/commit/69c722bfab98a4cb7f19d78ab71c87d3bb654971 Could a member of staff kindly check the last time the book was refreshed and work towards integrating these changes into the docbook so that we can get an update our to readers?

Addy Osmani
O'Reilly Author 
Apr 06, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 23
After var defineProp = function ( obj, key, value ){

A constructor pattern bug fix needs to be made to the code example at the position mentioned as follows https://github.com/addyosmani/essential-js-design-patterns/commit/598fd69d2c7529edfe059f94efcbc3a7ed64e153

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 23
After the line "// If the above feels a little difficult to read, a short-hand could // be written as follows:"

The config part of the code sample: var config = { value : value }; needs to be replaced as follows: https://github.com/addyosmani/essential-js-design-patterns/commit/dd66f3b1a5c988e3be55b33c8e2655717795c4d3

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 26
After There should be no comma used after the final name/value pair in the object, as this may result in errors.

A semi-colon change needs to be made to: al name/value pair in the object, as this may result in errors. var myObjectLiteral = { variableKey: variableValue, functionKey: function () { // ... }; }; as follows: https://github.com/addyosmani/essential-js-design-patterns/commit/ced28a246fadd52931b16811cefb9a85bc1c5eb8

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed
Page 36
First sentence under Advantages

The sentence states, "We've seen why the Singleton pattern can be useful, but why is the Module pattern a good choice?" The Singleton pattern hasn't been covered at this point, it is in the next section.

Note from the Author or Editor:
Confirmed. This sentence needs to be changed to "Let's now review how the Module pattern can be useful for structuring and encapsulating code".

Jared Goodpasture  Apr 21, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 44
Added an else-if branch to the Insert function.

In the function listed 'ObserverList.prototype.Insert = function( obj, index ){', added an else-if branch to the Insert function. The change that needs to be made as follows: https://github.com/addyosmani/essential-js-design-patterns/commit/470c6d58e623fc0122f415c7c3bbd467d668ba69

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 44
ConcreteObserver code sample

The code example: -ObserverList.prototype.RemoveAt = function( index ){ - if( index === 0 ){ - this.observerList.shift(); - }else if( index === this.observerList.length -1 ){ - this.observerList.pop(); - }else { - this.observerList.splice( index, 1 ); - } -}; needs to be changed as follows: https://github.com/addyosmani/essential-js-design-patterns/commit/a45f385746dc6fe283b9e1857cf2744ed17947cb

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 45
ObserverList.prototype.RemoveAt = function( index ){

The code sample starting at the location in the page specified needs to be updated as follows: https://github.com/addyosmani/essential-js-design-patterns/commit/a45f385746dc6fe283b9e1857cf2744ed17947cb

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 45
Mid-page

In the code sample: ObserverList.prototype.RemoveIndexAt() = function( index ){ if( index === 0 ){ this.observerList.shift(); }else if( index === this.observerList.length -1 ){ this.observerList.pop(); } }; we need to change it as follows https://github.com/addyosmani/essential-js-design-patterns/commit/d334d059b29c36612028bfbe8fbe3fec8fa7fd42

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
PDF, ePub
Page 47
Figure 9-4

Starting with Figure 9-4, the figures in Chapter 9 do not match with the section for which they are intended; so for instance, 9-4 shows the Mediator Pattern, but it is in the section for Publish/Subscribe Pattern. This continues for the remainder of the chapter.

Note from the Author or Editor:
This is very strange and doesn't match up with QC2, which did contain the diagrams in the correct positions (we did some further text tweaks to that, but not to diagrams). Page 47: 9-4. Confirmed that the Mediator pattern diagram is presented at the top of the page where the Publish/Subscribe diagram should be shown. Figure 9-5 should be the Mediator pattern diagram but is instead shown as the Prototype pattern diagram. Page 69: The Prototype Pattern diagram shows the Command pattern diagram. Figure 9-7: shows the facade pattern diagram where the command pattern diagram should be shown. Page 74: Figure 9-8 shows the Factory pattern where the Facade pattern should be shown. In short: it would appear that the final PDF that was distributed had the technical diagrams mixed up from page 47 onwards. The images themselves are correct, just positioned in the wrong places. We need to fix this by double checking the list of diagrams produced by the graphics department against each section expecting a diagram (basically the main section covering patterns).

Piers Hollott  Aug 28, 2012  Sep 14, 2012
Printed
Page 47
Diagram 9.4 at the top of the page

It's already been confirmed that the Publish/Subscribe diagram is missing from the pdf and ePub versions, and the Mediator diagram (the next section) is in it's place. It looks like all of the diagrams after that are shifted one space back. I just wanted to make it known this is also the case in the printed version of the book.

Note from the Author or Editor:
This was an issue I reported several months ago in one of the earlier versions of the book. I believe it has now been fixed in all newer versions, however we should have a member of staff confirm this too.

Jared Goodpasture  Apr 21, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 58
Mid-page

The following minor code changes need to be made to the code after "Here is the JavaScript code:". The change can be found here: https://github.com/addyosmani/essential-js-design-patterns/commit/e669d19af3ca4d3adcee7088d3f524b04c7ce277

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 160
myFunctionParam

I recently used the nested namespace plugin template, to find you couldn't overwrite the default options when initialising the plugin. It turns out that the myFunctionParam is confusing things. Removing it completely solved the issue for me.

Note from the Author or Editor:
To correct this issue, we should remove the myFunctionParam entry from the code for the nested namespacing plugin.

Dan Voyce  Jun 02, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 209
Various

Minor changes in consistency to code examples across module pattern chapter and namespacing chapter. We need to bring in the following change: https://github.com/addyosmani/essential-js-design-patterns/commit/95dba9b880f4660e0fc824b8aba9554f4669eb72

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 210
After // Outputs: hello world

Typo correction in the code sample after the location mentioned. The following change needs to be made: https://github.com/addyosmani/essential-js-design-patterns/commit/0b3f73125335d4a9e553666b2650dcfcdb6ef320

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Printed, PDF, ePub, Mobi, Safari Books Online, Other Digital Version
Page 214
end of page

The line "var mod = extend(myApp, "myApp.modules.module2");" needs to be changed as follows https://github.com/addyosmani/essential-js-design-patterns/commit/3f122e33d40c3f60b30188bf3836afca1a802920

Addy Osmani
O'Reilly Author 
Jun 09, 2013 
Mobi
Page 2015
The Revealing Module Pattern Code Sample

The publicSetName function in the Revealing Module Pattern code example is assigning its argument strName to a global variable, privateName. I think it should be assigning strName to privateVar. function publicSetName( strName ) { privateVar = strName; }

Note from the Author or Editor:
This error was addressed in the latest commits to the open-source version of the book. Please see Oct 27th onwards for the changes required to bring the latest inline with this: https://github.com/addyosmani/essential-js-design-patterns/commits/1.5.2

Jared Cacurak  Sep 17, 2012  Mar 01, 2013