Chapter 9: Optimizing JavaScript for Download Speed

Chapter 10: Optimizing JavaScript for Execution Speed

Strike the sentence "with also has been deprecated, so it is best avoided."

with is still in the ECMA JavaScript specification.

Page 228:

var serialData=new;
Array(-1,10,23...);

becomes:

var serialData=new
Array(-1,10,23...);

Page 232:

Listing 10.14 Flipped Loop with Optimized Reverse Count

As I mentioned in the text using the pre-decrement operator as a conditional in a while [while (--i);] assumes that
i is a positive integer. For values of i less than or equal to zero an infinite loop would result. If you are not sure that i will be greater than zero you can surround the do-while loop with a check for i>0 like this:

function loopDoWhileReverse3() {
var i=iter;
if (i>0) { // make sure i is positive here
do
{
// do something here
}
while (--i); // i must be greater than 0 here
}

Page 236:

Listing 10.18 Faster Duff's Device

Same fix as in listing 10.14. We assume when using the pre-decrement operator that n is positive. In this case with the division by eight, n must also be greater than or equal to 8. If you are not sure that the number of iterations will not equal or exceed the degree of unrolling you can surround the second do-while loop with a check for n>0 just like the first loop: