Wrox Programmer Forums
|
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
 
Old May 22nd, 2007, 10:50 AM
ufo ufo is offline
Authorized User
 
Join Date: Apr 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default some errata / questions

Hi,

I was finding some things i read strange and some against the ecmascript specs...

p196
It reads here that the function parameter of replace() takes one argument. It takes m+3 however. See below. In firefox it actually works that way also...

"If replaceValue is a function, then for each matched substring, call the function with the following m + 3 arguments. Argument 1 is the substring that matched. If searchValue is a regular expression, the next m arguments are all of the captures in the MatchResult (see 15.10.2.1). Argument m + 2 is the offset within string where the match occurred, and argument m + 3 is string. The result is a string value derived from the original input by replacing each matched substring with the corresponding return value of the function call, converted to a string if need be." from ecma standard 3rd ed. p102

Further down it says comma needs to be escaped. I use it with success without escaping. On the next page in the you also don't mention it as a metacharacter...

p579-580
Here you talk about a scope tree. however, to my knowledge fn1() could not access sMyLastName. Therefor there would absolutely be no reason to look up the scope chain like you put it. The ecma script standard defines it like this:


"The production FunctionDeclaration : function Identifier ( FormalParameterListopt ) { FunctionBody }
is processed for function declarations as follows:
1. Create a new Function object as specified in 13.2 with parameters specified by FormalParameterList, and body specified by FunctionBody. Pass in the scope chain of the running execution context as the Scope.
2. Create a property of the current variable object (as specified in 10.1.3) with name Identifier and value
Result(1)." ecma standard 3rd ed p71


As far as I'm concerned this would be the scope of the running context where the function is declared, not where it is called. (closures) Obviously it is still cheaper using local variables...

p585-586

In the for loops i is incremented both in the statements as in the for loop. this is probably a mistake

p588
I was just wondering where you got that do while is faster than while, and why is it faster?
Here: http://home.earthlink.net/~kendrasg/...l#loopflipping Jeff Greenburg seems to find that it do while is usually slower:

Loop flipping is the method of taking a loop that has it's condition evaluated at the top and changing it to evaluate at the bottom. Most of the time this seems to be inferior to a top evaluating loop in JavaScript, but there are times, which I haven't been able to predict, when bottom evaluating seems faster.

So I hope I did not make any mistakes,
curious what you think
greets
ufo
 
Old May 24th, 2007, 11:55 PM
nzakas's Avatar
Wrox Author
 
Join Date: Dec 2004
Posts: 217
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Hi ufo,

Thanks for your post. Pleae realize that this book is now over three years old and was written for optimal compatibility with IE 6 and Netscape 4. For that reason, there are some things that cater more to cross-browser implementation than modern standards. While I'm not 100% sure, I think some of the quirks you mention are directly related to that.

For your regular expression concerns, I believe that the comma needed to be escaped in Netscape 4 in order for it to work properly. Netscape's regular expression parser had many quirks, if memory serves.

The scope tree you mention is a bit inaccurate, now that I look at it.

The loops that have increments in the control and in the statement is intentional. This is a technique for speeding up the processing of loops.

For the do..while loop, I can honestly say I don't remember how I came across this information. Again, it may be related to the browsers of the time, but it's been three years so I'm not entirely sure.

Please review the errata for the book at http://www.wrox.com/WileyCDA/WroxTit...ew_errata.html. I think some of your issues may be covered there. And feel free to submit anything you think may be an error at any time.

Thanks!

Nicholas C. Zakas
Author, Professional JavaScript for Web Developers (ISBN 0764579088)
http://www.nczonline.net/
 
Old July 15th, 2007, 08:20 PM
ufo ufo is offline
Authorized User
 
Join Date: Apr 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

sorry for not responding so long. I have been extremely busy.

thanks for the clarification on the comma.

on the forloops. Well, you definitely speed them up by skipping some of the entries in the array, but that would have very limited use i reckon...:)

greets





Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET Interview Questions, C# Interview Questions, dotnetuncle .NET Framework 2.0 4 June 22nd, 2019 07:03 AM
A new errata Cookie Chen C# 1 November 12th, 2007 05:12 AM
Errata DaveSussman BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 November 6th, 2005 07:35 PM
Errata edsmithed BOOK: Professional Java Development with the Spring Framework 4 August 9th, 2005 04:32 PM
Errata ursjenzer BOOK: Professional Assembly Language 0 July 5th, 2005 09:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.