Book of JavaScript, Errata and Commentary
Although I tried my hardest to deliver a completely error-free book, nobody's perfect.
Below are the errors I and others have found in the Book of JavaScript, 2nd Edition:
Chapter 8
- Figure 8-17
- The line above line 6 should be:
the_string = the_string + " that he " + answers[2] + " a " + answers[3] + ".";
note the added + sign between answers[3] and the "."
Chapter 9
- Figure 9-10
- This is a code fragment, and not meant to run as it stands. I've updated
the code in the website's Chapter 9 directory to include a runnable version.
One problem is that on line 6 in the book, there's a curly brace which should be
removed. Not sure how that got in there. Thanks to James Pyles for letting me know about the error.
Chapter 10
- Figure 10-4
- There isn't an error here, but just something a little weird. In the navigation
file, I have some contents in the hrefs (e.g. href="http://www.wired.com"). So, if you click on the link, that web page appears in the navigation frame.
I think it's better, for the example, to put href="#" in there instead. Alternatively, if you wanted clicking on the link to open the web page in the content frame. You could make the links look like this:
<a href="http://www.wired.com" target="content" onMouseOver="...">
Chapter 11
- Figure 11-8
- The point of this example is to show the split() method being used.
The code does not ensure that the day, month and
year have two digits. It does check that the day, month and year are provided by
the user, and that reasonable numbers are given (e.g. months are between 1 and 12). The code for checking that the day, month and year have two digits would
have been distracting. To add that, add further conditions to the if-then statement, like (date_array[0].length == 2).
- Figure 11-10
- The third line should read :
if (mail_checker.test(the_email) == true) {
Thanks to Jeremy Riley for this one.
Chapter 13
- Figure 13-10
- Line 1 should really be :
the_div = document.getElementById("numberOne").style;
Also, the z-index:-1 should be removed from the div.
Chapter 14
- Figure 14-6
- When using the Firebug JavaScript debugger, you
need to select "Disable Network Monitoring" from the Options menu in
Firebug's Net tab in order for this example to work. Firebug will
prevent all XMLHttpRequests to external websites unless you do this. Thanks to Michael Passalacqua for pointing out
this issue.