Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0
This is the forum to discuss the Wrox book Professional JavaScript for Web Developers by Nicholas C. Zakas; ISBN: 9780764579080
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 9th, 2005, 10:59 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default Did you find a mistake?

Hey, mistakes happen, even to authors (especially first-time authors). If you think you've found a mistake in this book, please let me know by posting the information here. Once confirmed, we can post an official notice in the Errata section for the book to inform people of the mistake. Additionally, these changes can be incorporated into future print runs and editions of the book. So in effect, you help to make the book better!

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
__________________
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #2 (permalink)  
Old May 19th, 2005, 12:17 AM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

May be I am wrong but I think that example at the beginning of page 31 is not correct. The code is:

var oStringObject1 = new String("yellow");
var oStringObject2 = new String("brick");
var iResult = sTestString.localeCompare("brick");
if(iResult < 0) {
alert(oStringObject1 + " comes before " + oStringObject2);
} else if (iResult > 0) {
alert(oStringObject1 + " comes after " + oStringObject2);
} else {
alert("The two strings are equal");
}

Two string objects were defined, but localeCompare method called for third string object sTestString which was not defined and it is called with a literal parameter "brick". I supposed that definition was just omitted but further there are alerts which are telling us that oStringObject1 "comes before", "comes after" or equal to oStringObject2. But we didn't compare oStringObject1 with oStringObject2, though parameter value of localeCompare is equal to oStringObject2 constructor's parameter.

I think it was supposed to be

var oStringObject1 = new String("yellow");
var oStringObject2 = new String("brick");
var iResult = sStringObject1.localeCompare(oStringObject2);
if(iResult < 0) {
alert(oStringObject1 + " comes before " + oStringObject2);
} else if (iResult > 0) {
alert(oStringObject1 + " comes after " + oStringObject2);
} else {
alert("The two strings are equal");
}

or some other logic was implied.

There are also misprints on the same page (lines 2,3,4,5 and 22) where method localeCompare() is called localCompare().

I am using pdf version of this book in case there is inconsistency in page numbering.

Excuse my poor English.

Best Regards
P.S. I just start reading but I think the book is great.

Reply With Quote
  #3 (permalink)  
Old May 19th, 2005, 09:07 AM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

AGS,

You are correct, this is indeed a mistake. Thanks for letting me know.

Also, I found all the incorrect spellings of localCompare() you mentioned. You have a sharp eye! I'll log an erratum for each.

Thanks again.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #4 (permalink)  
Old May 19th, 2005, 04:14 PM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nicholas,
I am terribly sorry if it looks like fault-finding because actually it is not. I am just trying to make the best possible use of the book. So, several notes.

Page 42. Signed right shift
var iNew = iOld >> 5; //equal to binary 10 with is decimal 2
misprint in comment: “with is decimal” instead of “which is decimal”, but may be it’s only in my copy.

Page 42. Unsigned right shift
Is seems to me that the whole following paragraph has some misconception

 
Quote:
quote:For numbers that are negative, however, something quite different happens. You see, the unsigned right
Quote:
shift operator fills all empty bits with the value contained in the 32nd bit. For positive numbers, this bit
is 0; so the empty bits are filled with zero. For negative numbers, however, this bit is 1, meaning that all
empty bits are filled with 1. Because the result of unsigned right shift is an unsigned 32-bit number, you
end up with a very large number. For example, if you shift –64 to the right by five bits, you end up with
2147483616. How does this happen?
As far as I understand unsigned right shift operator (as opposed to signed right shift) fills empty bits with zeros. In other words it doesn’t fill them at all.
And at any rate if you shift -64 to the right by five bits with unsigned right shift operator, you end up with 134217726, not 2147483616.

And further

Page 43
 
Quote:
quote:First, look at the true 32-bit representation of –64. To do so, you need to create an unsigned version of the
Quote:
number, which can be attained by using unsigned right shift with a bit count of 0:
var iUnsigned64 = 64 >>> 0;
Then, to get the actual bit representation, use the toString() method of the Number type with a
radix of 2:
alert(iUnsigned64.toString(2));
I think a minus was omitted in expression “var iUnsigned64 = 64 >>> 0;”. It should be “var iUnsigned64 = -64 >>> 0;”.
We are talking about “the true 32-bit representation of –64.”, not 64.
Otherwise following “alert(iUnsigned64.toString(2));” will yields 1000000, not 11111111111111111111111111000000.

Finally (concerning my bad English I am quite uncertain) in my opinion in phrase “This yields a value of 11111111111111111111111111000000, which is the two’s complement representation of –64 for a signed integer, …” it would be better to say “which is two’s complement representation of 64”, because logically the binary number mentioned above is a two’s complement representation of 64, not -64. But once again may be I am wrong.

Best regards
Alexei

Reply With Quote
  #5 (permalink)  
Old May 19th, 2005, 07:19 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Alexei,

First off, apologies are not necessary. I want people you to tell me when you find mistakes so I can try to fix them or explain them better.

1) You are right, it should be "which is decimal" not "with is decimal". Good catch!

2) You are correct again. It is the signed right shift that fills in the bits with the sign bit. I wish I could find my notes for this section, I suspect I was trying to explain an example that was ultimately pulled. For instance, -64 >> 5 >>> 1 does return 2147483616.

3) There is indeed a minus sign missing in that example.

4) I can understand your confusion on this point. The number is the two's complement of 64, which actually represents -64. Perhaps I could have worded that better in order to avoid the confusion.

Thanks again for taking the time to dig into these issues. I really appreciate it (you'd make a good technical editor).

Nicholas

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #6 (permalink)  
Old May 21st, 2005, 10:47 AM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Nicholas,

Page 73, first code sample

Code:
var aColors = [“red”, “green”, “blue”];
var aColors2 = arr.concat(“yellow”, “purple”);
alert(aColors2.toString()); //outputs “red,green,blue,yellow,purple”
alert(aColors.toString()); //outputs “red,green,blue”
Presumably the second line should be
Code:
var aColors2 = aColors.concat("yellow", "purple");
and the same in the following example
Code:
var aColors = [“red”, “green”, “blue”, “yellow”, “purple”];
var aColors2 = arr.slice(1);
var aColors3 = arr.slice(1, 4);
alert(aColors2.toString()); //outputs “green,blue,yellow,purple”
alert(aColors3.toString()); //outputs “green,blue,yellow”
 
Quote:
quote:Here, aColors2 contains all the items in arr from position 1 on.

arr instead of aColors

As for your remark “you'd make a good technical editor”, well, I would be happy to edit your next book ;).

Best regards
Alexei
Reply With Quote
  #7 (permalink)  
Old May 21st, 2005, 04:41 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Location: Peabody, MA, USA.
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You've done it again, Alexei! Good eye! (I'm so embarassed)

If you're really interested in helping to edit the next book before it comes out, please drop me a line through my web site with your e-mail address. I can't pay you, but I can offer a free copy of the book and a word of thanks in it.

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
Reply With Quote
  #8 (permalink)  
Old May 22nd, 2005, 03:58 AM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Page 91
Misprint in example of factory function with parameters:
Code:
var oCar1 = createCar(“red”, 4, 23);
var oCar1 = createCar(“blue”, 3, 25);
oCar1.showColor(); //outputs “red”
oCar2.showColor(); //outputs “blue”
Variable oCar1 was defined twice instead of oCar2.
Best regards,
Alexei



Reply With Quote
  #9 (permalink)  
Old May 22nd, 2005, 11:08 AM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Page 98
Performance testing of StringBuffer object versus string concatenation:
Code:
var oBuffer = new StringBuffer();
d1 = new Date();
for (var i=0; i < 10000; i++) {
oBuffer.append(“text”);
}
var sResult = buffer.toString();
d2 = new Date();
document.write(“<br />Concatenation with StringBuffer: “ + (d2.getTime() -
d1.getTime()) + “ milliseconds”);
misprint: buffer instead of oBuffer
Best regards,
Alexei

Reply With Quote
  #10 (permalink)  
Old May 22nd, 2005, 01:32 PM
AGS AGS is offline
Wrox Technical Editor
Points: 267, Level: 5
Points: 267, Level: 5 Points: 267, Level: 5 Points: 267, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: Russia
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Default

at the very end of Page 101
 
Quote:
quote:It is not recommended that you use very late binding because it can be difficult to keep track of and document. However, you should understand that it is possible.

Probably I am wrong (sorry, if that’s the case), but may be end document was implied?
Best regards,
Alexei


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mistake in code yami56 Access 3 February 24th, 2005 04:04 PM
mistake in my topics zakarya_hazara Classic ASP Basics 1 October 9th, 2004 02:49 AM
Dangerous mistake revinchalil SQL Server 2000 4 February 4th, 2004 12:06 PM



All times are GMT -4. The time now is 09:18 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.