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 "Corrected".
The following errata were submitted by our customers and approved as valid errors by the author or editor.
| Version |
Location |
Description |
Submitted By |
Corrected |
| Printed |
Page Section 4.6
second block of code |
the function declaration is named try_it, but it then tries to call the function by tryIt().
|
Anonymous |
Sep 2008 |
| Printed |
Page xiii
Acknowledgments |
LeComte should be Lecompte (no camelCase).
Note from the Author or Editor: Lecomte not Lecompte
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page xiii
|
Location: Acknowledgments
Description: LeComte should be Lecompte (no camelCase).
|
Anonymous |
Sep 2008 |
| Safari Books Online |
4.12
last code block |
This line
seqer.set_prefix('Q';)
should be
seqer.set_prefix('Q');
|
Anonymous |
Nov 2008 |
| Safari Books Online |
4.12. Module
3rd code example |
Hello,
The third source code block in this section on Safari Books Online has:
"seqer.set_prefix('Q';)"
replace with:
"seqer.set_prefix('Q');" //move semicolon outside of parenthesis.
It is easy to figure out, but still confusing if you Cut+Paste the code and it wont run.
|
Anonymous |
Nov 2008 |
| Printed |
Page 10
Last paragraph, first sentence |
'based in' should be 'based on'.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 10
|
Location: Last paragraph, first sentence
Description: 'based in' should be 'based on'.
|
Anonymous |
Sep 2008 |
| Printed |
Page 10
last sentence |
In the last sentence of page 10, the word "then" should not be set in a constant width font since it is not a keyword; it should be italicized (like "truthy" in the same sentence was).
|
Anonymous |
Apr 2009 |
| Printed |
Page 13
in the code sample |
hasownProperty should be hasOwnProperty
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 13
|
Location: in the code sample
Description: hasownProperty should be hasOwnProperty
|
Anonymous |
Sep 2008 |
| Printed |
Page 16
in Table 2-1 replace "modulo" with "remainder" |
Also make this replacement in the diagram called "infix operator" on page 17 and page 129.
Note from the Author or Editor: In Table 2-1 replace "modulo" with "remainder".
Also make this replacement in the diagram called "infix operator" on page 17 and page 129.
|
 Douglas Crockford
 |
|
| Printed |
Page 21
First code sample under heading "Retrival" |
The code reads:
stooge["first-name"] // "Joe"
However, on the previous (p. 20) the property "first-name" is set to "Jerome". To be consistent, both values should be the same.
Note from the Author or Editor: It should be
stooge["first-name"] // "Jerome"
|
Anonymous |
Nov 2008 |
| Printed |
Page 22
|
Location: under Prototype, second paragraph, third line and in code below it
Changed beget to create
|
Anonymous |
Sep 2008 |
| Printed |
Page 23
|
Location: second code line at the top of page
Changed beget to create
|
Anonymous |
Sep 2008 |
| Printed |
Page 24
second code example |
The last two lines of the example are
}
}
Delete the next to last line:
}
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 24
|
Location: second code example
Description: The last two lines of the example are
}
}
Delete the next to last line:
}
|
Anonymous |
Sep 2008 |
| Printed |
Page 28
First code example |
value: 0;
should be
value: 0,
Note from the Author or Editor: Change the semicolon to a comma.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 28
|
Location: First code example
Description: value: 0;
should be
value: 0,
Notes from the Author: Change the semicolon to a comma.
|
Anonymous |
Sep 2008 |
| Printed |
Page 29
First code example |
Replace
that.value = add(that.value, that.value)
with
that.value = add(that.value, that.value);
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 29
|
Location: First code example
Description: Replace
that.value = add(that.value, that.value)
with
that.value = add(that.value, that.value);
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 29
last line of the first code example [9/08] |
the last line of the code example reads:
document.writeln(myObject.getValue()); // 6
this does not work, since the getValue() method is not defined on myObject. Safari 3.1.2 reports the error "TypeError: Value undefined (result of expression myObject.getValue) is not object." and Firefox 3 reports "Error: myObject.getValue is not a function".
The line should read:
document.writeln(myObject.value);
like in the code example on the previous page.
|
Anonymous |
Nov 2008 |
| Printed |
Page 29
end of first code example |
The last line of code uses a getter:
myObject.getValue()
This getter has not been defined. So access the property directly as on the previous page:
myObject.value
|
Anonymous |
Nov 2008 |
| Printed |
Page 32
last line of the second example |
tryIt should be try_it
|
Anonymous |
Sep 2008 |
| Printed |
Page 32
2nd code sample |
The last line of the code sample should reads:
tryIt();
instead it should read:
try_it();
since this is the name of the variable in which the function defined in the sample is stored.
|
Anonymous |
Sep 2008 |
| Printed |
Page 32
first code example |
Replace
}
}
with
};
}
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 32
|
Location: first code example
Description: Replace
}
}
with
};
}
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 32
|
Location: 2nd code sample
Description: The last line of the code sample should reads:
tryIt();
instead it should read:
try_it();
since this is the name of the variable in which the function defined
in the sample is stored.
|
Anonymous |
Sep 2008 |
| Printed |
Page 33
Second code example |
In the function it is tried to invoke the method 'ceiling' on Math which will fail because the method is named 'ceil'.
So instead of
return Math[this < 0 ? 'ceiling' : 'floor'](this);
it should read
return Math[this < 0 ? 'ceil' : 'floor'](this);
|
Anonymous |
Nov 2008 |
| Printed |
Page 33
2nd Example: 'integer' method |
Typo: Replace 'ceiling' by 'ceil':
Number.method('integer', function ( ) {
return Math[this < 0 ? 'ceil' : 'floor'](this);
});
|
Anonymous |
Nov 2008 |
| Printed |
Page 33
Code near bottom of page |
On page 33, the code at the top of the page includes `return this;' while the similar code at the bottom of the page is missing this statement.
|
Anonymous |
Apr 2009 |
| Printed |
Page 34
First code example |
Replace
}
}
with
}
};
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 34
|
Location: First code example
Description: Replace
}
}
with
}
};
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 37
First code example |
Replace
}
}
with
}
};
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 37
Second paragraph |
Replace getElementsByClassName with getElementsByAttribute
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 37
|
Location: First code example
Description: Replace
}
}
with
}
};
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 37
|
Location: Second paragraph
Description: Replace getElementsByClassName with getElementsByAttribute
|
Anonymous |
Sep 2008 |
| Printed |
Page 39
// BETTER EXAMPLE |
The "BETTER EXAMPLE" is broken. The fix to the first printing was still incorrect. The example should read
var add_the_handlers = function (nodes){
var i;
for( i=0; i < nodes.length; i += 1 )
{
nodes[i].onclick = function(i){
return function () {
alert(i);
};
}(i);
}
};
That works with IE and Firefox.
This mistake is pretty bad, I would have hoped the author tested the code! Thanks
Note from the Author or Editor: nodes[i].onclick = (function (i) {
return function (e) {
alert(i);
};
}(i));
|
Anonymous |
|
| Printed |
Page 39
BETTER EXAMPLE portion of code |
var add_the_handlers = function (nodes) {
var i;
for(i = 0; i < nodes.length; i += 1) {
nodes[i].onclick = function (i) {
return function (e) {
alert(i);
};
}(i);
}
};
should be
var add_the_handlers = function (nodes) {
var i;
for(i = 0; i < nodes.length; i += 1) {
nodes[i].onclick = function (i) {
return function (e) {
alert(e);
};
}(i);
}
};
where this alert e and not i
Note from the Author or Editor: Replace alert(i) with alert(e)
|
Anonymous |
Sep 2008 |
| Printed |
Page 39
First code example |
Replace
}
}
};
with
};
}
};
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 39
supposed corrected better example at 9780596517748.confirmed |
from 9780596517748.confirmed
var add_the_handlers = function (nodes) {
var i;
for(i = 0; i < nodes.length; i += 1) {
nodes[i].onclick = function (i) {
return function (e) {
alert(e);
};
}(i);
}
};
where this alert e and not i
Notes from the Author: Replace alert(i) with alert(e)
I thought the point of the example was to be able to display the ordinal value of the node. Instead it displays "[object MouseEvent]" for FireFox, "undefined" for IE (since no event passed with onclick property assignment).
Note from the Author or Editor: Replace alert(i) with alert(e)
|
Anonymous |
Sep 2008 |
| Printed |
Page 39
|
Location: First code example
Description: Replace
}
}
};
with
};
}
};
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 39
|
Location: BETTER EXAMPLE portion of code
Description: var add_the_handlers = function (nodes) {
var i;
for(i = 0; i < nodes.length; i += 1) {
nodes[i].onclick = function (i) {
return function (e) {
alert(i);
};
}(i);
}
};
should be
var add_the_handlers = function (nodes) {
var i;
for(i = 0; i < nodes.length; i += 1) {
nodes[i].onclick = function (i) {
return function (e) {
alert(e);
};
}(i);
}
};
where this alert e and not i
Replaced alert(i) with alert(e)
|
Anonymous |
Sep 2008 |
| Printed |
Page 41-42
code example beginning on page 41 and continuing on 42 |
code example should read:
var serial_maker = function() {
var prefix = '';
var seq = 0;
return {
set_prefix: function (p) {
prefix = String(p);
},
set_seq: function (s) {
seq = s;
},
gensym: function(){
var result = prefix + seq;
seq += 1;
return result;
}
};
} // need to remove the (); here otherwise serial_maker cannot be called.
var seqer = serial_maker();
seqer.set_prefix('Q'); // this line previously read seqer.set_prefix = 'Q';
seqer.set_seq (1000); // this line previously read seqer.set_seq = 1000;
var unique = seqer.gensym();
in particular, the current printed version returns an object, but seqer cannot equal serial_maker(); That is, either the parens happen at the function definition or they happen at the assignment, but they cannot happen at both.
also, the code example assigns values to setters, the correction uses the setters instead of overwriting them.
|
Anonymous |
Sep 2008 |
| Printed |
Page 41-42
|
Location: code example beginning on page 41 and continuing on 42
Description: code example should read:
var serial_maker = function() {
var prefix = '';
var seq = 0;
return {
set_prefix: function (p) {
prefix = String(p);
},
set_seq: function (s) {
seq = s;
},
gensym: function(){
var result = prefix + seq;
seq += 1;
return result;
}
};
} // need to remove the (); here otherwise serial_maker cannot be called.
var seqer = serial_maker();
seqer.set_prefix('Q'); // this line previously read seqer.set_prefix
= 'Q';
seqer.set_seq (1000); // this line previously read seqer.set_seq = 1000;
var unique = seqer.gensym();
in particular, the current printed version returns an object, but
seqer cannot equal serial_maker(); That is, either the parens happen
at the function definition or they happen at the assignment, but they
cannot happen at both.
Also, the code example assigns values to setters, the correction uses
the setters instead of overwriting them.
|
Anonymous |
Sep 2008 |
| Printed |
Page 41
the last line of the deentityfy function example |
The last line of the example reads:
}());
that is one closing parenthesis too many. It should be
}();
With the extra parenthesis the example will not run.
|
Anonymous |
Nov 2008 |
| Printed |
Page 41
first code sample (continued from page 40) |
The syntax at the end of the sample is incorrect. It should end with:
}());
instead of
}();
because the result of the function invocation is the last parameter to the String.method call beginning on the previous page. This is particularly bad since the text immediately following asks the reader to pay special attention to the line with the error on it. The result is confusing.
|
Neal Tucker |
Apr 2009 |
| Printed |
Page 42
code example |
The variable should hold the function value, not the object returned by a call to the function. Instead of:
var serial_maker = function () {
/* detail omitted */
}();
var seqer = serial_maker();
The code should read:
var serial_maker = function () {
/* detail omitted */
};
var seqer = serial_maker();
|
Anonymous |
Sep 2008 |
| Printed |
Page 42
End of first code block, the definition of serial_maker |
The serial_maker function should not be invoked when it is defined. Invoking it as shown in the book sets serial_maker to reference an object with 3 methods. The subsequent statement:
var seqer = serial_maker();
makes no sense since serial_maker is not a function.
You should remove the function invocation at the end of the serial_maker definition for the example to make sense.
Note from the Author or Editor: Replace the line
}();
with
};
|
Anonymous |
Sep 2008 |
| Printed |
Page 42
First code example |
replace
seqer.set_prefix = 'Q';
seqer.set_seq = 1000;
with
seqer.set_prefix('Q');
seqer.set_seq(1000);
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 42
|
Location: code example
Description: The variable should hold the function value, not the
object returned by a call to the function. Instead of:
var serial_maker = function () {
/* detail omitted */
}();
var seqer = serial_maker();
The code should read:
var serial_maker = function () {
/* detail omitted */
};
var seqer = serial_maker();
|
Anonymous |
Sep 2008 |
| Printed |
Page 42
|
Location: First code example
Description: replace
seqer.set_prefix = 'Q';
seqer.set_seq = 1000;
with
seqer.set_prefix('Q');
seqer.set_seq(1000);
|
Anonymous |
Sep 2008 |
| Printed |
Page 42
|
Location: End of first code block, the definition of serial_maker
Description: The serial_maker function should not be invoked when it
is defined. Invoking it as shown in the book sets serial_maker to
reference an object with 3 methods. The subsequent statement:
var seqer = serial_maker();
makes no sense since serial_maker is not a function.
You should remove the function invocation at the end of the
serial_maker definition for the example to make sense.
Notes from the Author: Replace the line
}();
with
};
|
Anonymous |
Sep 2008 |
| Printed |
Page 42
code example on the top |
There are two errors in this code example:
1) The definition of serial_maker is finished with () which invokes the anonymous function. That makes the next line: var seqer = serial_maker(); erroneous since serial_maker is not the function but the object returned by the anonymous function.
2) once the previous error is fixed the two lines:
seqer.set_prefix = 'Q';
seqer.set_seq = 10000;
should change to:
seqer.set_prefix('Q');
seqer.set_seq(10000);
|
Anonymous |
Nov 2008 |
| Printed |
Page 42
middle of the page |
seqer.set_prefix('Q';)
should be
seqer.set_prefix('Q');
|
 Douglas Crockford
 |
Nov 2008 |
| Printed |
Page 42
3rd line from bottom in code example on top of page |
This line:
seqer.set_prefix('Q';)
should be:
seqer.set_prefix('Q');
|
Craig Doremus |
Nov 2008 |
| Printed |
Page 42
Code at top of page, third to last line |
The wrong quote is used here. It should be the ASCII apostrophe: 'Q'
|
Anonymous |
Apr 2009 |
| Printed |
Page 47
4th line of code in middle of page |
The code listing on page 47 of Crockford's book Javascript - The Good Parts is missing a semicolon, namely:
// Create a new object that inherits from the
// constructor's prototype
var that = Object.beget(this.prototype)
|
Anonymous |
Sep 2008 |
| Printed |
Page 47
second code example |
Replace
var that = Object.beget(this.prototype)
with
var that = Object.beget(this.prototype);
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 47
|
Location: second code example
Description: Replace
var that = Object.beget(this.prototype)
with
var that = Object.beget(this.prototype);
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 47
|
Location: 4th line of code in middle of page
Description: The code listing
Javascript - The Good Parts is missing a semicolon, namely:
// Create a new object that inherits from the
// constructor's prototype
var that = Object.beget(this.prototype)
|
Anonymous |
Sep 2008 |
| Printed |
Page 50
In the second example |
Add "middle: m," on the line after "last: l,".
|
 Douglas Crockford
 |
|
| Printed |
Page 51
first code example |
return this.says + ' ' + this.name + ' ' + this.says;
apparently should be:
return this.says() + ' ' + this.name + ' ' + this.says();
like the similar correct example on page 49.
|
Anonymous |
Sep 2008 |
| Printed |
Page 51
|
Location: first code example
Description: return this.says + ' ' + this.name + ' ' + this.says;
apparently should be:
return this.says() + ' ' + this.name + ' ' + this.says();
like the similar correct example on page 49.
|
Anonymous |
Sep 2008 |
| Printed |
Page 51
|
Description: second line, first line of code, 10th line of code from the bottom,
Changed beget to create
|
Anonymous |
Sep 2008 |
| Printed |
Page 52
last line of code example |
Replace
}
with
};
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 52
|
Location: last line of code example
Description: Replace
}
with
};
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 52
|
Description: 14th line from top
Changed beget to create
|
Anonymous |
Sep 2008 |
| Printed |
Page 53
|
Description: 12th line from top
Changed beget to create
|
Anonymous |
Sep 2008 |
| Printed |
Page 54
In code in the middle of the page |
The "that.get_name" method needs a closing curly bracket to end the function before the "return that;" statement.
The code as given:
that.get_name = function () {
return that.says() + ' ' + spec.name +
' ' + that.says();
return that;
The code should be:
that.get_name = function () {
return that.says() + ' ' + spec.name +
' ' + that.says();
};
return that;
|
Anonymous |
Nov 2008 |
| Printed |
Page 54
code example "var cat" |
Missing
};
before
return that;
at end of function definition.
Note from the Author or Editor: In the middle of the page.
that.get_name = function () {
return that.says() + ' ' + spec.name +
' ' + that.says();
};
return that;
}:
|
Anonymous |
Nov 2008 |
| Safari Books Online |
54
second code block |
This error is in the Print version and the Safari Online version. On Page 54, the second code block where the function "cat" is defined, the get_name method does not have a closing parenthesis.
var cat = function (spec) {
spec.saying = spec.saying || 'meow';
var that = mammal(spec);
that.purr = function (n) {
var i, s = '';
for (i = 0; i < n; i += 1) {
if (s) {
s += '-';
}
s += 'r';
}
return s;
};
that.get_name = function ( ) {
return that.says( ) + ' ' + spec.name +
' ' + that.says( );
return that;
};
The get_name function should be:
that.get_name = function ( ) {
return that.says( ) + ' ' + spec.name +
' ' + that.says( );
};
return that;
Note from the Author or Editor: that.get_name = function () {
return that.says() + ' ' + spec.name +
' ' + that.says( );
};
|
Anonymous |
Nov 2008 |
| Printed |
Page 59
1st paragraph |
The original text follows:
--------------------------
The object literal:
var numbers_object = {
'0': 'zero', '1': 'one', '2': 'two',
'3': 'three', '4': 'four', '5': 'five',
'6': 'six', '7': 'seven', '8': 'eight',
'9': 'nine'
};
produces a similar result. Both numbers and number_object are objects containing 10 properties, and those properties have exactly the same names and values. But there are also significant differences. numbers inherits from Array.prototype, whereas number_object inherits from Object.prototype, so numbers inherits a larger set of useful methods. Also, numbers gets the mysterious length property, while number_object
-----------------------------
Original text is complete
The code names the array "numbers_object", the text refers to "number_object". It is true that this is only a 1 character typo, but fixing it ought to reduce potential confusion.
|
Anonymous |
Sep 2008 |
| Printed |
Page 59
first paragraph, lines 8 and 12 (see line 2) |
The name of an object is missing a letter
reads: number_object
should be: numbers_object
Note from the Author or Editor: There are two places in the paragraph where number_object should be replaced with numbers_object
|
Anonymous |
Sep 2008 |
| Printed |
Page 59
|
First paragraph, lines 8 and 12 (see line 2)
The name of an object was missing a letter
was: number_object
now reads: numbers_object
There are two places in the paragraph where number_object should be replaced with
numbers_object
|
Anonymous |
Sep 2008 |
| Printed |
Page 60
Last paragraph of "Delete" section |
The book reads: "The property whose value is 'shi' has its key changed from '4' to '3'."
It should read: "from '3' to '2'."
|
Anonymous |
Nov 2008 |
| Printed |
Page 63
second code example |
Replace
return a;
}
with
return a;
};
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 63
|
Location: second code example
Description: Replace
return a;
}
with
return a;
};
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 63
|
Description: 9th line from top
Changed beget to create
|
Anonymous |
Sep 2008 |
| Printed |
Page 64
Code block after 1st paragraph |
From the context, it seems this part:
for (j = 0; j < n; j += 1) {
a[j] = 0;
}
should be:
for (j = 0; j < n; j += 1) {
a[j] = initial;
}
- otherwise the "initial" parameter is quite pointless.
|
Anonymous |
Sep 2008 |
| Printed |
Page 64
second code example |
Replace
return mat;
}
with
return mat;
};
Make this change in both places.
Note from the Author or Editor: Add a semicolon.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 64
|
Location: second code example
Description: Replace
return mat;
}
with
return mat;
};
Make this change in both places.
Notes from the Author: Add a semicolon.
|
Anonymous |
Sep 2008 |
| Printed |
Page 64
|
Location: Code block after 1st paragraph
Description: From the context, it seems this part:
for (j = 0; j < n; j += 1) {
a[j] = 0;
}
should be:
for (j = 0; j < n; j += 1) {
a[j] = initial;
}
- otherwise the "initial" parameter is quite pointless.
|
Anonymous |
Sep 2008 |
| Printed |
Page 68
2/3rds down, paragraph that starts with Note |
Replace "want we want" with "what we want".
|
 Douglas Crockford
 |
|
| Printed |
Page 69
Bottom footnote |
In the press them all together regex, there's an extra ? (between the ) and ( )
... a-z]+)?(?::( ...
or there's a ? missing from the
var parse_url = ... on page 66.
Note from the Author or Editor: Replace +)?(?:: with +)(?:: by deleting the ? between the parens.
|
Anonymous |
Sep 2008 |
| Printed |
Page 69
|
Location: Bottom footnote
Description: In the press them all together regex, there's an extra ?
(between the ) and ( )
... a-z]+)?(?::( ...
or there's a ? missing from the
var parse_url = ... on page 66.
Notes from the Author: Replace +)?(?:: with +)(?:: by deleting the ?
between the parens.
|
Anonymous |
Sep 2008 |
| Printed |
Page 71
line with new RegExp |
the following:
new RegExp("\"(?:\\.|[^\\\\\\\"])*\"", 'g'))
should be the following:
new RegExp("\"(?:\\\\.|[^\\\\\\\"])*\"", 'g'))
|
Anonymous |
Nov 2008 |
| Printed |
Page 74
3rd paragraph, regular expression example |
The regular expression given in the example:
var doubled_words = /[A-Za-z\u00C0-\u1FFF\u2800-\uFFFD'\-]+\s+\1/gi;
does not include any capturing parens to allow the \1 backreference to work. I believe the corrected version should be:
var doubled_words = /([A-Za-z\u00C0-\u1FFF\u2800-\uFFFD'\-]+)\s+\1/gi;
|
Anonymous |
Sep 2008 |
| Printed |
Page 74
|
3rd paragraph, regular expression example
The regular expression given in the example:
var doubled_words = /[A-Za-zu00C0-u1FFFu2800-uFFFD'-]+s+1/gi;
does not include any capturing parens to allow the 1 backreference to work. Corrected version
now reads:
var doubled_words = /([A-Za-zu00C0-u1FFFu2800-uFFFD'-]+)s+1/gi;
|
Anonymous |
Sep 2008 |
| Printed |
Page 74
middle |
The edition of the book I have has a single character instead of the required `\u' for each of the four separate UniCode hex enumerations in the regular expression. This single character resembles a crescent moon and may be (or: is similar to) \u02D8.
Also, why is there a ' (single quote) character in the regular expression? ( It appears between FFFD and the closing ] )
In summary, the regex for var doubled_words should use the "simple letter class" from the first sentence of the first paragraph on the page.
Note from the Author or Editor: The example has been mangled. The expression inside the [ ] should match the expression in the page's first sentence.
|
Anonymous |
Apr 2009 |
| Printed |
Page 86
|
Description: under Object, second line of code
Changed beget to create
|
Anonymous |
Sep 2008 |
| Printed |
Page 88
string.charAt(pos) |
Replace
String.method('charAt', function () {
return this.slice(0, 1);
});
with
String.method('charAt', function (pos) {
return this.slice(pos, pos + 1);
});
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 88
|
Location: string.charAt(pos)
Description: Replace
String.method('charAt', function () {
return this.slice(0, 1);
});
with
String.method('charAt', function (pos) {
return this.slice(pos, pos + 1);
});
|
Anonymous |
Sep 2008 |
| Printed |
Page 89
2nd paragraph |
replace "localCompare" with "localeCompare"
|
 Douglas Crockford
 |
|
| Printed |
Page 90
3rd paragraph, string.replace sample for replacing an old phone area code |
Hi,
Revision: First Edition
Page: 90
The 3rd paragraph on this page, which discusses string.replace, has the following code sample:
var oldareacode = /\((\d{3})\)/g;
var p = '(555)666-1212'.replace(oldareacode, '$1-');
// p is '555-555-1212'
The given answer is incorrect. var p is 555-666-1212.
Thanks for such a good book that is informative, intelligent and non-patronising. I hope O'Reilly and the author will publish more books like this!
Mark
|
Anonymous |
Nov 2008 |
| Printed |
Page 91
1st code block under string.split(separator, limit) |
The text says:
var digits = '0123456789';
var a = digits.split('', 5);
// a is ['0', '1', '2', '3', '456789']
a is actually ['0', '1', '2', '3', '4']
Note from the Author or Editor: // a is ['0', '1', '2', '3', '4']
|
Micah Stetson |
|
| Printed |
Page 98
next to last line |
'firortranst' should be 'first'
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 98
|
Location: next to last line
Description: 'firortranst' should be 'first'
|
Anonymous |
Sep 2008 |
| Printed |
Page 105
Last code example |
Replace
function isNumber...
with
var isNumber = function isNumber(value) {
return typeof value === 'number' && isFinite(value);
};
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 105
|
Location: Last code example
Description: Replace
function isNumber...
with
var isNumber = function isNumber(value) {
return typeof value === 'number' && isFinite(value);
};
|
Anonymous |
Sep 2008 |
| Printed |
Page 117
Table C-1 |
Table C-1 does not jive with Options listed at http://www.jslint.com/#options ( and the JSLint Options listed at http://www.jslint.com/lint.html ) -- the latter has more options than Table C-1
In particular, Table C-1 is lacking:
newcap
css
indent
onevar
predef
regexp
safe
sidebar
strict
sub
Furthermore, Table C-1 lists "glovar," which does not appear in the JSLint Options listed at http://www.jslint.com/lint.html
Finally, there are 28 options listed in the JSLint Options at http://www.jslint.com/lint.html while there are only 26 at http://www.jslint.com/#options
Note from the Author or Editor: Remove the line that starts with glovar.
|
kovacs |
Apr 2009 |
| Printed |
Page 122
++ and -- |
replace
enabling to viruses
with
enabling viruses
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 122
|
Location: ++ and --
Description: replace
enabling to viruses
with
enabling viruses
|
Anonymous |
Sep 2008 |
| Printed |
Page 134
middle |
Delete the first while diagram.
Note from the Author or Editor: while was included twice.
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 134
|
Location: middle
Description: Delete the first while diagram.
Notes from the Author: while was included twice.
|
Anonymous |
Sep 2008 |
| Printed |
Page 134
After diagram for throw statement |
In the first printing of the book (May 2008), the diagram for the try statement is missing from Appendix D.
I do not know if this error was fixed in the September 2008 printing of the book.
This error has been fixed in the Safari Online edition of the book (viewed 2008 December 29).
Note from the Author or Editor: The diagram for the try statement is missing.
|
Anonymous |
Apr 2009 |
| Printed |
Page 136
middle |
JSON has six kinds of values:
Replace string with strings
|
 Douglas Crockford
 |
Sep 2008 |
| Printed |
Page 136
|
Location: middle
Description: JSON has six kinds of values:
Replace string with strings
|
Anonymous |
Sep 2008 |
| Printed |
Page 136
4th line |
shoulddwell => should dwell
|
 Douglas Crockford
 |
Nov 2008 |
| Printed |
Page 140
last section of code |
Missing commas - replace last section with:
escapee = {
'"': '"',
'\\': '\\',
'/': '/',
b: 'b',
f: '\f',
n: '\n',
r: '\r',
t: '\t'
},
|
Anonymous |
Apr 2009 |
| Printed |
Page 147
|
Description: under arrays
Object.beget method changed to Object.create method
|
Anonymous |
Sep 2008 |
| Printed |
Page 151
|
Description: Object.beget method changed to Object.create method
|
Anonymous |
Sep 2008 |