 |
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
|
|
|

June 8th, 2005, 07:33 AM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Example at the end of page 201:
Quote:
quote:For example, suppose you want to match words bread, read, or red. Using the question mark quantifier,
|
Quote:
you can create just one regular expression to match all three:
var reBreadReadOrRed = /b?rea?d/;
|
strictly speaking there is another match - "bred", but may be it does not matter in this context.
page 205, first paragraph
Quote:
quote:This section introduces these concepts and more, so you can use you regular expressions to
|
Quote:
make complex string manipulations easier.
|
misprint? your
Best regards,
Alexei
|

June 8th, 2005, 02:56 PM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I think there is misconception in RegExp exec() methodâs examples on pages 194-195.
page 194
Quote:
quote:The RegExp exec() method, which takes a string as an argument, returns an Array containing all
|
Quote:
matches. Consider the following example:
|
and further there are examples with and without option g , and finally (on page 195) with gi options applied:
Code:
var sToMatch = âa bat, a Cat, a fAt baT, a faT catâ;
var reAt = /at/gi;
var arrMatches = reAt.exec(sToMatch);
and a table with contents of resulting arrMatches array values.
Iâve tried to reproduce these examples, but alas - arrMatches length property always gave me 0. At last (after several hours :)) Iâve found an explanation: exec() method returns an array but only first element contains current match, elements with indexes from 1 to n contain stored backreferences (if any).
http://developer-test.mozilla.org/en...ts:RegExp:exec
So the following paragraphs on page 195 are not correct regarding exec() and match() functional similarity
Quote:
quote:The String object has a method called match(), which intentionally mirrors the functionality of the
|
Quote:
RegExp objectâs exec() method. The main difference is that the method is called on the String object
and the RegExp object is passed in as an argument:
Code:
var sToMatch = âa bat, a Cat, a fAt baT, a faT catâ;
var reAt = /at/gi;
var arrMatches = sToMatch.match(reAt);
This code yields the same result as the previous example, with arrMatches containing all the same
items.
|
because match() does return an array containing all matches.
And there is inconsistency with page 213 where there is a correct example of exec() method functionality.
Best regards,
Alexei
|

June 8th, 2005, 04:34 PM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Page 204. Reluctant quantifier "behind the scenes" behaviour examples.
There are definitely superfluous "//true â match!" comments instead of "//false - no match":
Code:
re2.test(âaâ); //false - no match
re2.test(âaaâ); //false - no match
re2.test(âaabâ); //false - no match
re2.test(âaabbâ); //true â match!
re2.test(âaabbbâ); //true â match!
//store this result and start with next letter
re2.test(âaâ); //false - no match
re2.test(âaaâ); //false - no match
re2.test(âaaaâ); //false - no match
re2.test(âaaabâ); //true â match!
re2.test(âaaabbâ); //false - no match
re2.test(âaaabbbâ); //true â match!
//store this result and start with next letter
Best regards,
Alexei
|

June 8th, 2005, 08:37 PM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Great catches again, Alexei. I'm going to have to really look into the exec() issue, thanks for the link on that one. I've submitted all of these to Wrox for inclusion in the errata on the web site.
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
|

June 9th, 2005, 07:54 AM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Not an error, just a note
page 182. Dom Traversal, first paragraph.
Quote:
quote:Up until this point, the features discussed have all been part of DOM Level 1. This section introduces
some of the features of DOM Level 2, specifically objects in the DOM Level 2 Traversal and Range specification
relating to traversing a DOM document. These features are only available in Mozilla and
Konqueror/Safari.
|
I can't give it a try on Safari but current version of Mozilla (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511) gave me
Quote:
quote:Error: uncaught exception: [Exception... "Component returned failure code: 0x80004001
|
Quote:
(NS_ERROR_NOT_IMPLEMENTED) [nsIDOMDocumentTraversal.createNodeIterator]" nsresult: "0x80004001 (NS_ERROR_NOT_IMPLEMENTED)" location: "JS frame :: http://localhost/test_dom.html :: makeList :: line 18" data: no]
|
on code blocks with createNodeIterator (pages 184-186)
Best regards,
Alexei
|

June 15th, 2005, 09:55 AM
|
Registered User
|
|
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Nicholas and Alexei.
1) About shifting, I think that there is an error when in the book we find "... The left shift fills these bits with the value in the 32nd bit..."(page 41- Left shift). Left shift operation inserts always 0 bits on the right side of 32bits signed integer, but preserves bit 31 (sign bit) from shifting.
2)
Quote:
quote:
For instance, -64 >> 5 >>> 1 does return 2147483616.
|
Does -64>>>1 return 2147483616 ?
Isn't it?
3) Page 39
Quote:
quote:
3. The one's complement is converted back to a floating-point number.
|
Isn't better to say 32-bit number?
Best regard.
Paolo
|

June 15th, 2005, 10:18 AM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Alexei:
Yes, NodeIterator was never fully implemented in Mozilla (doh!). It was allegedly supposed to be done but never was. I'll have to update that.
Paolo:
Yes, the description of shifting is pretty messed up, as Alexei pointed out earlier. And you're right, -64 >>> 1 does return 2147483616 (this is why answering forum posts at work is never a good idea).
And you're right, 32-bit number is better than floating-point number. Good catch.
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
|

June 18th, 2005, 02:40 PM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Page 274, last paragraph
Quote:
quote:The keyCode property always contains a code the represents the key pressed, which may or may not
|
Quote:
represent a character. For example, the Enter (or Return) key has a keyCode of 13, the space bar has a
keyCode of 32, and the BackSpace key has a keyCode of 8.
|
misprint? that
Page 287
I have vague fillings that last sentence is worded unclearly:
Quote:
quote:So, if you set the onload
|
Quote:
event handler on the <body/> element and then check the window.onload property, you see the following
code has been placed there:
<html>
<head>
<title>Onload Example</title>
<script type=âtext/javascriptâ>
function handleLoad() {
alert(window.onload);
}
</script>
<body onload=âhandleLoad()â>
</body>
</html>
|
Because if I âset the onload event handler on the <body/> element and then check the window.onload propertyâ, Iâll see âthe following code has been placed thereâ:
Code:
function anonymous() { handleLoad() }
but may be itâs my bad perception of English
Page 288, first code block
Code:
<html>
<head>
<title>Onload Example</title>
<script type=âtext/javascriptâ>
document.body.onload = function () {
alert(âloadedâ);
}
</script>
<body>
</body>
</html>
</head> tag is not closed
Best regards,
Alexei
|

June 18th, 2005, 06:45 PM
|
 |
Wrox Author
|
|
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Alexei,
You're right on all counts. The second one certainly doesn't make any sense at all. For once I actually found one before you, the </head> issue. I can't wait to have you look over my new book. :)
Nicholas
Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
|

June 20th, 2005, 09:16 AM
|
Wrox Technical Editor
|
|
Join Date: May 2005
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Nicholas:
Once again I am not perfectly sure, but...
Page 312, last paragraph
Quote:
quote:Microsoft offers a currentStyle object on each element that includes all properties from the element
|
Quote:
background-color object as well the properties from any relevant CSS ruleâs style object. The
currentStyle object works in the exact same way as the style object, with all the same properties
and methods. This means that even if a background color is defined in a CSS rule, currentStyle.
backgroundColor still contains the correct value:
|
I guess just element's style object was implied.
As for your new book, I can't wait too, but I'm afraid that it will be irreproachable and my help won't be needed :).
|
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 |
|
 |