Errata

Developing Large Web Applications

Errata for Developing Large Web Applications

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 24
code sample

New variables, such as Account and BankAccount, should be declared with var.

Michael Bolin  Mar 20, 2010 
Printed Page 24
code sample

The example of creating a static variable is absolutely wrong. If you run the following code:

var Account = function(amount, lowest) {
this.balance = amount;
this.minimum = lowest;
};

Account.prototype.deposits = 0;

Account.deposits++;

Then Account.deposits will be NaN because its initial value is 'undefined' and then it is incremented with the unary ++ operator.

Declaring a property on Account.prototype is the default value of deposits for an instance of Account, but once an Account modifies that value, it redefines that property on itself, shadowing the value on its prototype:

var a = new Account(0, 0);
a.deposits = 1;
var b = new Account(0, 0);

alert(a.deposits); // alerts 1
alert(b.deposits); // alerts 0

Clearly, the value does not behave like a "static" variable as a and b have different values for it.

The value should initially be declared as:

Account.deposits = 0;

Then it would work with the implementation of incrementDeposits() on page 25, though it is confusing since the following is incorrectly declared again at the top of that page:

Account.prototype.deposits = 0;

Michael Bolin  Mar 20, 2010 
Printed Page 24-25
Multiple locations

There is serious confusion in this chapter on the part of the author between prototype properties of functions and internal prototype references of objects. The prototype property is what a (constructor) function uses to expose properties to its instances. This property is only of use on functions. On the other hand, the internal prototype reference is defined for any object and is used by JavaScript internally to construct prototype chains and facilitate property resolution. This reference is not directly accessible to JavaScript code (although some implementations expose it, like Mozilla with the __proto__ property -- see, e.g., http://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/proto ).

At the top of p.24,

"When you invoke the constructor with new, JavaScript sets the prototype property of the created object to the prototype property of the constructor."

should read

"When you invoke the constructor with new, JavaScript sets the internal prototype reference of the created object to the prototype property of the constructor."

On p.25 in "Inheritance in JavaScript", all references to "prototype property" on an instance object should be changed to "internal prototype reference".

John Peloquin  Nov 25, 2010 
Printed Page 25
Code sample

In addition to Michael Bolin's corrections,

Account.prototype.incrementDeposits = function () {
...
};

should read

Account.incrementDeposits = function () {
...
};

In general, static variables or functions should be declared directly on the constructor function itself, not on the prototype. The prototype is for exposing properties to instances.

John Peloquin  Nov 25, 2010 
Printed Page 26
code sample

Even though this is a dummy declaration, it is incorrect and misleading:

BankAccount.prototype.withdraw(amount)

This should be:

BankAccount.prototype.withdraw = function(amount)
{
// Whatever
};

Also, despite the frequent references to Crockford, the examples do not follow his recommended brace style:

BankAccount.prototype.withdraw = function(amount) {
// Whatever
};

It's not as significant for function declarations, but it is important when declaring object literals in JavaScript, so it is cleaner to be consistent and use the K&R style exclusively when writing JS.

Michael Bolin  Mar 20, 2010 
Printed Page 44
Under 'Attribute values', first two paragraphs and their examples.

Great book. It's exactly what I've been looking for for 3 years now but couldn't find. But I stumbled upon reading these paragraphs.

Maybe this is a minor technical mistake considering that writing code as mentioned causes no harm, but considering that the whole topic of XML and HTML and style versus structure and the competing ideologies about data, semantics, etc., I don't think O'Reilly needs to add to the confusion. (I'm a devoted Amazon/O'Reilly buyer)
Although I could be mistaken because my review several years ago
(and again now) was rapid due to lack of time, I believe the official XHTML documents are mute on this issue and defer to XML 1.0 which also is mute in its offical text, but if you read the actual DTD definition, either double quotes or single quotes can be used to enclose attribute values. What you can't do is mix them in the same attribute value, but you can, within the same element or across elements, change your quoting character! It's useful to use single quotes when you want to embed a double quote in the value (and vice-versa). I habitually use single quotes because it's a bit easier to type, especially on my international spanish keyboard where the upcased double quote is separated from the single quote way up and to the left on the keyboard.
See the XHTML spec. and which refers to XML 1.0 and
"http://www.w3.org/TR/2000/REC-xml-20001006" (XML 1.0 DTD annot.) section 'literals' item [9]. It's reasonably clear if your neurotically afflicted with the computer bug. ;)

Anonymous  Aug 26, 2010 
Printed Page 89
Example 5-1

In the code sample,

var GreenSearchResultsModel.MReg = new Array();
var GreenSearchResultsModel.VReg = new Array();

should read

GreenSearchResultsModel.MReg = new Array();
GreenSearchResultsModel.VReg = new Array();

John Peloquin  Nov 27, 2010 
Printed Page 122
Example 6-8

In the code sample,

class NewCarListingsDataManager

should read

class NewCarListingsDataManager extends DataManager

John Peloquin  Nov 27, 2010 
Printed Page 126
Example 6-10

In the get_details method, the $id value should be scrubbed to prevent SQL injection vulnerabilities.

John Peloquin  Nov 27, 2010 
Printed Page 159
Example 7-4

In the code sample, there is a superfluous right curly bracket after the Google Analytics code.

John Peloquin  Nov 27, 2010 
Printed Page 186-7
Example 8-1

In the native XHR example, there are other HTTP statuses besides 200 that indicate success.

John Peloquin  Nov 27, 2010 
Printed Page 204
Example 8-9

In the TestModel recover method,

// Implement this method to do whatever is needed to handle timeouts.

should read

// Implement this method to do whatever is needed to handle failure.

John Peloquin  Nov 27, 2010 
Printed Page 209
Example 8-11

In the unsubscribe method,

if (this.views[i].id == view.id)

should read

if (this.views[i].id != view.id)

John Peloquin  Nov 27, 2010 
Printed Page 217
Example 8-14

In the code,

var GreenSearchResultsModel.MReg = new Array();
var GreenSearchResultsModel.VReg = new Array();

should read

GreenSearchResultsModel.MReg = new Array();
GreenSearchResultsModel.VReg = new Array();

John Peloquin  Nov 27, 2010 
Printed Page 232
Example 9-6

In the code,

WineSearchResultsModel.prototype.abandon

should read

GreenSearchResultsModel.prototype.abandon

John Peloquin  Nov 27, 2010 
Printed Page 242
Example 9-10

In the code sample, there is a superfluous right curly bracket after the Google Analytics code.

John Peloquin  Nov 27, 2010