Errata

Head First JavaScript

Errata for Head First JavaScript

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
Page xxxii
3rd Paragraph/3rd picture at top

Elaine Nelson's picture has Elaine Norman over it instead of Elaine Nelson

Anonymous    Apr 01, 2011
Printed
Page 9, 11
lines 8 and 14 of p9, 3rd para of p11

I checked this with my boyfriend, who is a software developer. Both of us think that the actual conditional is commented out in two places. Given that the functions are called validateSomething, this must be a mistake.

Note from the Author or Editor:
The first two functions near the top of the listing should have the comments (// ) removed.

Anonymous  Sep 16, 2008  Apr 01, 2011
Printed
Page 9
Sharpen your pencil exercise

At the bottom, the code line "onclick="findHouses(this.form);" />" should not be circled; instead, two lines up, the code "onclick="calcPrice();" />" should be circled.

Anonymous    Feb 01, 2008
Printed
Page 33
In the cloud

In the statement "Every lady needs needs a special place to store treasured" ... "needs" is put twice.

Anonymous    Feb 01, 2008
Printed
Page 46
Watch it!

It is not made clear enough that constants are not supported by Internet Explorer. Use "var" instead of
the "const" keyword in all code examples in chapter 2.

Note from the Author or Editor:
This isn't really an error but I agree that we should've made it clearer that Internet Explorer is one of the browsers that doesn't support const - use var instead.

Anonymous    Apr 01, 2011
48
Bullet Points at the bottom of the page, 4th point

instead of "keyboard" it should read "keyword":
The var keyboard is used to create variables
The var keyword is used to create variables

Note from the Author or Editor:
Page 49, actually.

Anonymous  Aug 08, 2008  Jun 01, 2010
Printed
Page 49
column 2, top question

Please delete the apostrophe in the word "it's"; it should be "its".

Anonymous    Apr 01, 2011
Printed
Page 49
Next to last Bullet Point (bottom right of page)

The word "keyboard" should be "keyword". So it should read "The var keyword is used..."

Anonymous    Feb 01, 2008
Printed
Page 54
bottom left

Some one has already reported this partially:

"{54} bottom;
The caption beside the leftover magnets at the bottom of page 54 says, "All these leftovers are illegal names in JavaScript." But one of the magnets is named "eclairRECORDHOLDER". While this name does not conform to the unofficial standards, it certainly is legal."

In addition, to what the earlier report pointed out the magnet named "alarm_status" is a legal though non-conforming JavaScript identifier name.

So basically the fix would be to change the caption to read something like this:

"All these leftovers are illegal names, or do not conform to the unofficial community standards for identifier names in JavaScript."

I hope this helps.

Note from the Author or Editor:
The suggested change to the annotation is good.

Anonymous  Sep 14, 2008  Apr 01, 2011
Printed
Page 73, 74

Missing "==" in code on the fourth line in between the two dashed blanks. Line 2 has the same "==" done correctly.

Anonymous    Feb 01, 2008
Printed
Page 74

Fifth line of code in solution is missing an extra closing parenthesis magnet at the end (right after the word "value").

Anonymous    Feb 01, 2008
Printed
Page 81
13 Across

"An piece of data . . ." should be either "A piece of data . . ." or "Any piece of data . . ."

Note from the Author or Editor:
Should be "A piece of data...".

Anonymous   
Printed
Page 93
First sentence

... a timer in JavaScript is 1) establishing...

should be

... a timer in JavaScript are 1) establishing...

Anonymous    Feb 01, 2008
Printed
Page 94
1st paragraph 3rd line

Instead of ....headfirstlabs.com/books/hfsd it should read ....headfirstlabs.com/hfjs.

Note from the Author or Editor:

Anonymous    Apr 01, 2011
PDF
Page 109
Watch it! sidebar

Watch it! sidebar graphic covers some of the sidebar content. This appears to be the case for all Watch it! sidebars throughout the book.

Note from the Author or Editor:
this appears to be a problem with all Watch it! graphics from the 2011-04-11 printing

Anonymous  Feb 08, 2012 
Printed
Page 117
2nd sentence

"Unlike a variable, athough..."
should be
"Unlike a variable, though..."

Anonymous    Feb 01, 2008
Printed
Page 125
Sentence 2nd sentence of Answer 4

"That one important..." (improper sentence construction)
Possible alternate:
"That is one important..."

Anonymous    Feb 01, 2008
Printed
Page 140
last sentence

The last sentence ends with
...or sometimes even more that.
should probably be
...or sometimes even more than that.

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  May 21, 2008  Apr 01, 2011
Printed
Page 144
Last paragraph, 1st sentence

"...let the user to navigate through..."
should be
"...let the user navigate through..."

Anonymous    Feb 01, 2008
Printed
Page 153
Arrow top left in decision tree

In the two choices between Scene 2 and Scene 4:

The two choices after coming to the "little house in the woods" is in reality

- Walk around side
- Knock on door

While in the book it says that the choices are

- Walk around side
- Wave at witch <---this is wrong, and should be "Knock on door"

Note from the Author or Editor:
The suggested change is correct. And actually, the text "Walk around side." should also be changed - it should be "Walk around back."

Anonymous  Nov 06, 2008  Apr 01, 2011
Printed
Page 164
Bottom left (expressions) paragraph

At end of last sentence, "...handy for construction decision making..."
should be "...handy for constructing decision making..."

Anonymous    Feb 01, 2008
Printed
Page 165
No Dumb Questions - answer 2

In addition to null, 0 and "", undefined is handled similarly, so var d = null;, var d = 0, var d = ""; and var d; all work for answer d of the subsequent exercise.

For clarification, the annotation on page 66 below the blank for d should read: "d must be false so that !d is true. d could also be null, 0, ??, or even left empty (undefined), in which case !d will still be true."

Anonymous    Feb 01, 2008
Printed
Page 170
middle of sample code

there is a semi-colon missing after the

curScene = 2

in the middle of the sample code.

Anonymous    Apr 01, 2011
Printed
Page 173

The answer for the next-to-last NDQ needs to be completely changed. Instead of referring to current JS, it refers to JS2, which isn't supported in any real browsers yet. Here's a new answer:

<<<
A: Maybe. The current version of JavaScript (1.7) doesn't support true local scope for variables. Instead,
it supports function scope, which means variables within a given function are considered local variables
to that function. But just sticking a variable inside of a compound statement doesn't automatically make
it a local variable, although a future version of JavaScript will likely remedy this situation. The easy
way to remember it is that variables created inside of a function are local, while all others are global.
>>>

Anonymous    Apr 01, 2011
Printed
Page 173
No Dumb Questions - answer 3, sentence 2

"Comments are lables..." should be
"Comments are labels..."

Anonymous    Feb 01, 2008
Printed
Page 201
top of 3rd column

I believe the word "inconventional" s/b "unconventional".

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  May 22, 2008  Apr 01, 2011
Printed
Page 217
2nd paragraph

The sentence
...it's worth making changes to your code so that is more "elegant"
s/b
...it's worth making changes to your code so that it is more "elegant"

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  May 22, 2008  Apr 01, 2011
Printed
Page 226
2nd to last sentence on page

The sentence -
I am aware that there are lot of different...
s/b
I am aware that there are a lot of different...

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  May 22, 2008  Apr 01, 2011
Printed
Page 232
2nd paragraph, 1st sentence

"...of the array elements, o it makes sense..." should be
"...of the array elements, so it makes sense...

Anonymous    Feb 01, 2008
Printed
Page 237
2nd paragraph

Under the second large paragraph with the seat# functions, <img id="seat14" src=" alt="" /> is missing a quotation mark under src=. It should be <img id="seat14" src="" alt="" /> instead.

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  Jul 10, 2008  Apr 01, 2011
Printed
Page 261
Sidenote pointing to thermostat picture

The sentence

The "current temperature" display lets users know the current temperature so that they can make adjust the heat with more accuracy.

s/b

The "current temperature" display lets users know the current temperature so that they can adjust the heat with more accuracy.

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  May 22, 2008  Apr 01, 2011
Printed
Page 273-274
The code in the exercise and the exercise solution should be changed from

function doThis(num) {
return num++;
}

function doThat(num) {
return num--;
}

var x = doThis(11);
var y = doThat;
var z = doThat(x);
x = y(z);
y = x;
alert(doThat(z - y));

to:

function doThis(num) {
num++;
return num;
}

function doThat(num) {
num--;
return num;
}

var x = doThis(11);
var y = doThat;
var z = doThat(x);
x = y(z);
y = x;
alert(doThat(z - y));

Note from the Author or Editor:

Anonymous    Apr 01, 2011
Printed
Page 293
Third code block on page

The last line of the code block should not end with a semicolon. The code should read:

function showIt(theForm) {
alert(theForm["zipcode"].value);
}

Anonymous    Apr 01, 2011
Printed
Page 295
Title at the top of the page

the title
Form field follow a chain of events
s/b
Form fields follow a chain of events

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  May 22, 2008  Apr 01, 2011
Printed
Page 302
Second line of code block

The code in the onblur handler should end with a semicolon. This second line of code should read:

onblur="validateNonEmpty(this, document.getElementById('phone_help'));" />

Note from the Author or Editor:

Anonymous    Apr 01, 2011
Printed
Page 321
Bottom left corner above the Exercise

The first two slashes in the regular expression ^/d/ are reversed. The correct code is /^d/. As a reference, the correct version of the code does appear on the page already, just above and to the left of the first paragraph of text.

Anonymous    Feb 01, 2008
Printed
Page 323
What's My Purpose exercise

For consistency, the positions of second and sixth answer options in the right column should be swapped
("The sub-pattern is required..." and "The sub-pattern is optional..."), so the ordering of the right
column matches the ordering on the following page of solutions.

Note from the Author or Editor:

Anonymous  Jan 21, 2009  Apr 01, 2011
Printed
Page 326
Steps numbered 2 and 3 above last paragraph

The steps in question describe what the validateRegEx() function should do. Step 2 states that if the pattern matches, the help message should be set to the help text passed in and false should be returned. If the pattern matches, shouldn't the help text be cleared and true returned as described in step 3? It appears that step 2 should read "If the pattern doesn't match..." and step 3 should read "If the pattern matches...". The code on page 327 shows the implementation the correct way--if the pattern doesn't match, set the help message and return false. Otherwise, clear the help message and return true.

Note from the Author or Editor:
Step 2 of page 326 should be changed to start "If the pattern doesn't match, ..." and Step 3 should be change to start "If the pattern does match, ...".

Anonymous  Dec 04, 2008  Apr 01, 2011
Printed
Page 434
diagram at top

The box with the text "ceiling()" should instead contain the text "ceil()"

Anonymous    Apr 01, 2011
Printed
Page 434, 436
Exercise and Exercise solution

The second code line should read "Math.ceil(Math.PI)", not "Math.ceiling(Math.PI)"

Note from the Author or Editor:

Anonymous    Apr 01, 2011
458
1st handwritten paragraph

initializing is misspelled in the sentence:
Now the constructor focuses solely on creating and initalizing the properties.

Note from the Author or Editor:
Typo in first annotation - should be "initializing".

Anonymous  Dec 28, 2008  Apr 01, 2011
Printed
Page 483

In Page Bender, the "Missing Image" box in the bottom-center should not be part of the picture.

Anonymous    Feb 01, 2008
Printed
Page 488
First sentence of last paragraph

The sentence

Safari points out that the error is on entirely different line of code,

s/b

Safari points out that the error is on an entirely different line of code,

Note from the Author or Editor:
Should be fixed according to the errata description.

Anonymous  May 23, 2008  Apr 01, 2011