 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

May 9th, 2005, 10:59 AM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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/
|

May 19th, 2005, 12:17 AM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

May 19th, 2005, 09:07 AM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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/
|

May 19th, 2005, 04:14 PM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 19th, 2005, 07:19 PM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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/
|

May 21st, 2005, 10:47 AM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 21st, 2005, 04:41 PM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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/
|

May 22nd, 2005, 03:58 AM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 22nd, 2005, 11:08 AM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

May 22nd, 2005, 01:32 PM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
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 |
|
 |