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
  #21 (permalink)  
Old June 8th, 2005, 07:33 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

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

Reply With Quote
  #22 (permalink)  
Old June 8th, 2005, 02:56 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

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


Reply With Quote
  #23 (permalink)  
Old June 8th, 2005, 04:34 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

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

Reply With Quote
  #24 (permalink)  
Old June 8th, 2005, 08:37 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

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/
Reply With Quote
  #25 (permalink)  
Old June 9th, 2005, 07:54 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

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

Reply With Quote
  #26 (permalink)  
Old June 15th, 2005, 09:55 AM
PC PC is offline
Registered User
 
Join Date: Jun 2005
Location: Roma, , Italy.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #27 (permalink)  
Old June 15th, 2005, 10:18 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

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/
Reply With Quote
  #28 (permalink)  
Old June 18th, 2005, 02:40 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

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

Reply With Quote
  #29 (permalink)  
Old June 18th, 2005, 06:45 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,

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/
Reply With Quote
  #30 (permalink)  
Old June 20th, 2005, 09:16 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:
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 :).

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 04:52 AM.


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