Errata for Pragmatic Guide to JavaScript
We try to keep our books accurate, but sometimes mistakes creep
in. This page lists the errors submitted by our astute readers.
If you've found a new error, please
submit it.
The latest version of the book is P1.0,
released over 2 years ago.
If you've bought a PDF of the book and would like to upgrade
it to this version (for free), visit your
home page.
| PDF |
Paper |
Description |
Found in |
Fixed in |
|
7 |
#49514: One of the reported errata is itself possibly incorrect. There reported errata in question is:
"#46276: JavaScript code in 'Try this example: "privates properties.", var publicField = 'foobar'; should be publicField = 'foobar'; --Klaus Rohe"
The code in the book is correct. Either version (that in the book or that suggested by Klaus) will work. I verified this in a JavaScript console myself.
However, the book's version exports "publicField" by making it a property on the object returned from the anonymous function. The version suggested in the errata report, that of removing the "var" before the definition of the "publicField" variable is unnecessary. In fact, the only effect it has is to make said variable global (in the context in which you run said example). This actually breaks the spirit and intent of the code example and of what the section of the book it trying to demonstrate: keeping your own junk out of the global namespace.
Here's my console session log (executed in the Chrome Browser's JavaScript Console):
> var obj1 = (function() { var privateField = 42; var publicField = 'foobar'; function processInternals() { alert('Internal stuff: ' + privateField); } ; function run() { processInternals(); alert('Still private stuff: ' + privateField); alert('Public stuff: ' + publicField); } ; return { publicField: publicField, run: run }; })();
=> undefined
> var obj2 = (function() { var privateField = 43; publicField = 'foobar2'; function processInternals() { alert('Internal stuff: ' + privateField); } ; function run() { processInternals(); alert('Still private stuff: ' + privateField); alert('Public stuff: ' + publicField); } ; return { publicField: publicField, run: run }; })();
=> undefined
> obj1.run()
=> undefined
> obj1.publicField
=> "foobar"
> obj1.processInternals()
=> TypeError: Object #<Object> has no method 'processInternals'
> obj1.privateField
=> undefined
> obj2.run()
=> undefined
> obj2.publicField
=> "foobar2"
> obj2.processInternals()
=> TypeError: Object #<Object> has no method 'processInternals'
> obj2.privateField
=> undefined
> publicField
=> "foobar2"--Kendall Gifford #49514: One of the reported errata is itself possibly incorrect. There reported errata in question is:
"#46276: JavaScript code in 'Try this exampl ...more...
|
P1.0
12-Jul-12
|
|
|
7 |
#46276: JavaScript code in 'Try this example: "privates properties.", var publicField = 'foobar'; should be publicField = 'foobar'; --Klaus Rohe
|
P1.0
20-Jan-11
|
|
| 31 |
|
#45803: Y.one('#id').append('<p>This gets at top</p>')
is incorrect, it should be:
Y.one('#id').append('<p>This gets at bottom</p>')--Paul Mallet
|
P1.0
28-Nov-10
|
|
| 35 |
|
#45648: "document.observe('dom:ready', fx)" should read "document.observe('dom:loaded', fx)", correct?--Glen van de Mosselaer
|
B2.0
19-Nov-10
|
|
|
98 |
#45938: The top of the JavaScript Cheat Sheet identifies it as the "Pocket Guide to JavaScript's" cheat sheet rather than the "Pragmatic Guide to JavaScript's".--Sven Aas #45938: The top of the JavaScript Cheat Sheet identifies it as the "Pocket Guide to JavaScript's" cheat sheet rather than the "Pragmatic Guide to Java ...more...
|
P1.0
09-Dec-10
|
|
|
98 |
#45939: I was hoping the Guide (or at least the Cheat Sheet) would include a reminder of JavaScript's odd way of defining a new class. Perhaps in a future update?--Sven Aas #45939: I was hoping the Guide (or at least the Cheat Sheet) would include a reminder of JavaScript's odd way of defining a new class. Perhaps in a fu ...more...
|
P1.0
09-Dec-10
|
|
|
102 |
#45937: Missing space in the first paragraph of section B.2: "grab Firebug at [URL]or from the Mozilla Add-Ons directory" (at the end of the first URL).--Sven Aas
|
P1.0
09-Dec-10
|
|
| 112 |
|
#45775: Sixth line starting from the bottom:
"load scripts at the bottom of the " and even more [...]
The word 'page' is probably missing. --Arnaud Meuret
|
P1.0
26-Nov-10
|
|
| 114 |
|
#45776: Last ¶:
Most of use web developers
=>
Most of us web developers--Arnaud Meuret
|
P1.0
26-Nov-10
|
|
| 117 |
|
#45777: Middle of page:
PDoc (a code inline documentation system)
=>
PDoc (an inline code documentation system) ?--Arnaud Meuret
|
P1.0
26-Nov-10
|
|
| 119 |
|
#45835: "jQuery is, at the time of this writing, at version 1.4.2."
This was already mentioned at the bottom of the previous page:
"(The current version at the time of this writing is 1.4.2.)"
It seems a bit redundant to state this fact less than 1 page later.
Also, the current release is 1.4.4.--Eric Litwin #45835: "jQuery is, at the time of this writing, at version 1.4.2."
This was already mentioned at the bottom of the previous page:
"(The current v ...more...
|
P1.0
30-Nov-10
|
|
| 1999 |
rlZta |
#48804: Dear Lynne, This meiratal was so helpful! Thanks so much for taking the time to make it available to all of us. And, it came at the perfect time for me. Much Gratitude, Barb Bolin--mPKRFUrgVw #48804: Dear Lynne, This meiratal was so helpful! Thanks so much for taking the time to make it available to all of us. And, it came at the per ...more...
|
P1.0
25-Feb-12
|
|