Skip to main content

Professional JavaScript for Web Developers

Professional JavaScript for Web Developers

Nicholas C. Zakas

ISBN: 978-0-764-59763-3

Apr 2005

670 pages

Select type: E-Book

$25.99

Product not available for purchase

Description

  • Dispels the myth that JavaScript is a "baby" language and demonstrates why it is the scripting language of choice used in the design of millions of Web pages and server-side applications
  • Quickly covers JavaScript basics and then moves on to more advanced topics such as object-oriented programming, XML, Web services, and remote scripting
  • Addresses the many issues that Web application developers face, including internationalization, security, privacy, optimization, intellectual property issues, and obfuscation
  • Builds on the reader's basic understanding of HTML, CSS, and the Web in general

This book is also available as part of the 4-book JavaScript and Ajax Wrox Box (ISBN: 0470227818). This 4-book set includes:

  • Professional JavaScript for Web Developers (ISBN: 0764579088)
  • Professional Ajax 2nd edition (ISBN: 0470109491)
  • Professional Web 2.0 Programming (ISBN: 0470087889)
  • Professional Rich Internet Applications: Ajax and Beyond (ISBN: 0470082801)
Acknowledgments.

Introduction.

Chapter 1: What Is JavaScript?

Chapter 2: ECMAScript Basics.

Chapter 3: Object Basics.

Chapter 4: Inheritance.

Chapter 5: JavaScript in the Browser.

Chapter 6: DOM Basics.

Chapter 7: Regular Expressions.

Chapter 8: Browser and Operating System Detection.

Chapter 9: All about Events.

Chapter 10: Advanced DOM Techniques.

Chapter 11: Forms and Data Integrity.

Chapter 12: Sorting Tables.

Chapter 13: Drag and Drop.

Chapter 14: Error Handling.

Chapter 15: XML in JavaScript.

Chapter 16: Client-Server Communication.

Chapter 17: Web Services.

Chapter 18: Interacting with Plugins.

Chapter 19: Deployment Issues.

Chapter 20: The Evolution of JavaScript.

Index.

Download the code files for the book.
Code downloads for this title are available here.
Download
Download the code files for the book.
Download
Download the code files for the book.
Code downloads for this title are available here.
Download the code files for the book.
Corrected Pages 194-195
This is a corrected version of pages 194-195 fixing the errata noted on 6/15/2005
Download
ChapterPageDetailsDatePrint Run
7Wrong Prefix for Arrays in Chapter 7
In chapter 7, the code uses \ arr\ as a prefix for arrays, instead of the stated \ a\ - as mentioned on page 14.
5/16/05

viiError in Text, 2nd Paragraph
Page vii (Acknowledgements), 2nd paragraph:

First are foremost should read First and foremost .
5/30/05

122nd bulleted paragraph, first line in bold:
Comments are the same as in Java, C, and Perl

should be:

Comments are the same as in Java, C, and PHP
5/4/05

23Error in Text
2nd paragraph after the Converting to a number heading, line 7, near the end of the line:

Text reads:
one

Should read:
once
07/19/2006

24Error in Text
Bullet list, 3rd item

casts the given value a string
should be
casts the given value as a string
11/28/05

26Error in Text
1st bullet list, 2nd item, 2nd line

For the all classes
should be :
For all classes
11/28/05

27Error in code
First line of code:

oBooleanaobject
should be:
oBooleanObject
11/28/05

33First Line
\ Is variable s an instance of the class String?\

Should be:

\ Is variable oStringObject an instance of class String?\
5/16/05

41Error in text
Last paragraph, 2nd sentence reads:
The left shift fills these bits with the value in the 32nd bit (the sign bit)...

It should say:
The left shift fills these bits with 0's...
4/19/06

42Replace binary string
At the end of the first paragraph, the long binary string should be:
11111111111111111111111111111110
4/19/06

42Replace paragraph
replace last paragraph with:
For numbers that are negative, though, something quite different
happens. You see, the unsigned right shift operator fills all empty
bits with zeroes. For positive numbers, this behaves exactly the same
as the signed right shift. Negative numbers, however, are treated as
if they are positive. Since the result of unsigned right shift is a
positive 32-bit number, you end up with a very large number whenever
operating on a negative number. For example, if you shift –64 to the
right by five bits, you end up with 134217726. How does this happen?
4/19/06

43Error in text
First paragraph, second sentence should say:
To do so, you need to convert this number to its unsigned equivalent
(though the number itself is still signed behind the scenes), which
can be attained...
4/19/06

43Error in code
First code snippet should be: var iUnsignedNeg64 = -64 >>> 0;
4/19/06

43Error in code
Second code snippet should be:
alert(iUnsignedNeg64.toString(2));
4/19/06

44Error in variable names
In first paragraph, all variable names (3 instances)

found
should be:
bFound .

This includes changing !found to !bFound.
11/28/05

45Missing Word in Sentence
2nd paragraph, last sentence:

If this example is changed so that a is set to false, the error won't occur:
should read:
If this example is changed so that the first operand is set to false, the error won't occur:
7/6/05

46Error in text
3rd paragraph, first sentence:
As with the previous example, the variable c is undefined.

should read:
As with the previous example, the variable bUnknown is undefined.
7/6/05

52Re-wording of Sentence
Paragraph before Assignment Operators heading, last sentence:

If, however, the expression is false (meaning that iNum2 is less than or equal to iNum1), iNum2 is assigned to iMax.

should read:

If, however, the expression is false (meaning that iNum2 is greater than or equal to iNum1), iNum2 is assigned to iMax.
7/6/05

67First Sentence Should Begin...
Last paragraph, first sentence should begin:

As I discussed briefly in Chapter 2,
7/6/05

69First Sentence Should Begin...
First paragraph, first sentence should begin:

In Chapter 2, .
7/6/05

71Error in Code Block
Code block just before the gray shaded box, last line:

alert(arr.length); //outputs 26
Should say:
alert(aColors.length); //outputs 26
6/21/05

73Error in Code Block
First code block 2nd line (highlighted):

var aColors2 = arr.concat( yellow , purple );
should be:
var aColors2 = aColors.concat( yellow , purple );
6/21/05

73Error in Code
2nd code block 2nd line (highlighted) and 3rd line:

var aColors2 = arr.slice(1);
var aColors3 = arr.slice(1, 4);
should be:

var aColors2 = aColors.slice(1);
var aColors3 = aColors.slice(1, 4);
6/21/05

77Error in Text
2nd text paragraph, last line.

I discussed this further in Chapter 12
should be:
This is discussed further in Chapter 12
11/28/05

78Error in Code
Last three code examples should use 2004 instead of 2003 in the code.
7/6/05

79Text Error
Top of page, first sentence:

Internet Explorer displays February 2, 2003 as Sat Feb 2 00:00:00 EST 2003 while Mozilla displays it as Tue Feb 2 2003 00:00:00 GMT-0400 (Eastern Daylight Time) .

Should say:

Internet Explorer displays February 2, 2003 as Sun Feb 2 00:00:00 EST 2003 while Mozilla displays it as Sun Feb 02 2003 00:00:00 GMT-0400 (Eastern Daylight Time) .
6/20/05

84Re-wording of Description of LOG10E
Second table, 5th line, description of LOG10E:
The base 1 logarithm of E.
should be:
The base 10 logarithm of E.
7/6/05

386Error in Table
table at the bottom of page:
the function atan2(y, x) has the definition of Returns the arc cosine of y/x
arc cosine
should be
arc tangent
10/25/07

89Error in Text
3rd paragraph:
this is equal to car

should read:
this is equal to oCar
7/23/06

91Error in Code
2nd code block, 3rd line from end:
var oCar1 = createCar( blue , 3, 25);

should be:
var oCar2 = createCar( blue , 3, 25);
4/17/06

95Error in text
1st paragraph 4th line

so when it output
should be:
so when it outputs
11/28/05

130Error in Text, 2nd Paragraph
Second paragraph, 4th line:

inside of inline code

should be :

instead of inline code
5/30/05

143Code Error
First paragraph:

input()
should be:
prompt() .
8/24/05

162Error in Text
first paragraph, end:
instead of ending with (???)

the first paragraph should end:
notation appear first.
5/25/06

171Error in Code Block
Second to last code block first line:

var oPs = document.getElementsByTagname( p );
should be:
var oPs = document.getElementsByTagName( p );
7/6/05

193Error in Text
first paragraph, end of line 3:
gred

should be:
grep
3/24/06

194Error in Text
Next to last paragraph first sentence:

The RegExp exec() method, which takes a string as an argument, returns an Array containing all matches.

should read:

The RegExp exec() method, which takes a string as an argument, returns an Array. The first item in the array is the first match ; the others are backreferences (which will be discussed shortly).
6/15/05

194Error in Text
Last paragraph. Insert the following after the first sentence:

But of what use is returning an array with only one item? Suppose you want to get all of the occurrences of a pattern. This is where a different method can be used.
6/15/05

194Deletions in Last Paragraph
Last paragraph:

Delete 2nd sentence, delete 3 lines of code at end of page.
6/15/05

194-195Corrected Pages
A corrected version of pages 194-195 fixing the errata noted on 6/15/2005 is available in PDF format.

You can download it here: http://www.wrox.com/WileyCDA/WroxTitle/productCd-0764579088,descCd-download_code.html
12/29/05

195Deletions on Page
Delete the first paragraph, first code block, and paragraph following first code block
6/15/05

195Error in Text
Replace the paragraph after the table with:

The String object has a method called match(), which returns an array of all matches within the string. The method is called on the String object and the RegExp object is passed in as an argument:
6/15/05

195Replacing Text
Paragraph (single sentence) after the 2nd code block, replace with:

This code fills the aMatches with all of the instances of at in the order in which they appear in sToMatch. Here are the contents of the aMatches array after this code executes:
6/15/05

195Move Table
Move the table to follow the new paragraph:

This code fills the aMatches with all of the instances of at in the order in which they appear in sToMatch. Here are the contents of the aMatches array after this code executes:
6/15/05

195Error in Text
Paragraph before the final code block, first sentence:

A String method calls search() that acts the same way
should be :
Another String method called search()acts the same way
6/15/05

204Error in Code Block
Large code block:
9th line:

re2.test( aabb ); //true - match!
should be:
re2.test( aabb ); //false - no match
6/15/05

204Error in Code Block
Large code block:
15th line:

re2.test( aaab ); //true - match !
should be:
re2.test( aaab ); //false - no match
6/15/05

205Text Error
First paragraph, last sentence:

This section introduces these concepts and more, so you can use regular expressions to make complex string manipulations easier.

Delete the word you before regular expressions .
6/15/05

206Text Error/Code Error
First line of code:

var reExtraSpace = /^\s+(.*?)\s*$/;
should be:
var reExtraSpace = /^\s*(.*?)\s*$/;


paragraph following that: change the first sentence to:
This regular expression looks for zero or more occurrences of white space at the beginning of the string, followed by any number of additional characters (which are captured in a group), followed by zero or more occurrences of white space at the end of the string.
1/05/06

222Error in Code
First code block:

var reEmail = /^(?:\w+\.?)*\w+@^(?:\w+\.?)*\w+$/;

should be:

var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/;
6/16/05

222Error in Code
2nd code block, 2nd line:

var reEmail = /^(?:\w+\.?)*\w+@^(?:\w+\.?)*\w+$/;

should be:

var reEmail = /^(?:\w+\.?)*\w+@(?:\w+\.)+\w+$/;
6/16/*05

222Replace Sentence
6th text paragraph, replace 2nd sentence with:

Immediately after that is the non-capturing group (?:\w+\.), which can appear one or more times, so the plus sign is used.
6/16/05

6236Replace Code
Replace the shaded section of code completely with this:

for (var i=0; i < aVersion1.length; i++) {
var iVal1 = parseInt(aVersion1[i], 10);
var iVal2 = parseInt(aVersion2[i], 10);

if (iVal1 < iVal2) {
return -1;
} else if (iVal1 > iVal2) {
return 1;
}
}

return 0;
5/30/06

6236Add Line in Text
In the paragraph immediately following the code, insert this sentence immediately after the first sentence:

The values in each array are first converted to integers for comparison.
05/30/2006

269Error in Code
oDiv.addEventListener(\ onclick\ , fnClick1);
oDiv.addEventListener(\ onclick\ , fnClick2);

Should be:
oDiv.addEventListener(\ click\ , fnClick1, false);
oDiv.addEventListener(\ click\ , fnClick2, false);
5/16/05

273Error in Table
In table, first column, 13th row:
pageX

should be:
pageY
5/25/06

274Text Error
Last paragraph: the first sentence:

always contains a code the represents
should be :
always contains a code that represents
6/20/05

287Text Error
Last paragraph: Last sentence should read :

So, if you set the onload event handler on the <body/> element and then check the window.onload property (as in the following example), you will see that the event handler code has been placed there.
6/20/05

287Add New Line to Code Block
Last code block:

After the line with the </script> tag (the 8th line), add a new line:
</head>

This new line should be indented the same as the <head> line, the 2nd line of code.
6/20/05

299Error in Code
Page 299, code block at top, the shaded line:

Code reads:
oEvent.time = (new Date).getTime();

Should read:
oEvent.timeStamp = (new Date()).getTime();
07/14/2006

312Text Error
Last paragraph, first sentence:

Microsoft offers a currentStyle object on each element that includes all properties from the element background-color object as well the properties from any relevant CSS rule's style object.

Should read:

Microsoft offers a currentStyle object on each element that includes all properties from the element's style object as well the properties from any relevant CSS rule's style object.
6/20/05

320Error in Code
Second-to-last paragraph, 2nd sentence:

Also, startOffset is equal to 0, because the <p/> element is the first child of <p/>

should read:

Also, startOffset is equal to 0, because the <p/> element is the first child of <body/>
6/21/05

327Error in Code Block
Last code block 5th line:

oRange.setStartBefore(oP2);
should be:
oRange.setEndBefore(oP2);
7/6/05

239Error in Text
under heading Detecting Konqueror/Safari , third text paragraph, first line:
The first four strings are from Konqueror; the last two are from Safari.

should be:
The first four strings are from Konqueror; the last three are from Safari.
8/17/06

351Error in Code
Near bottom of page, first code line in the first code section under the Blocking paste heading and again in the first code line in the second code section:

Beginning of line

<input type= text onkeypress= return allow
should be
<input type= text onkeypress= return TextUtil.allowChars
12/22/05

462Error in Code
Starting with the 4th code line not counting blanks

oXmlDom.addEventListener( load , function () {
this.__initError__();
this.__changeReadyState__(4);
}, false);

should be:

oXmlDom.addEventListener( load , function () {
this.__checkForErrors__();
this.__changeReadyState__(4);
}, false);
3/16/06

470Error in Code
Second-to-last code example, 2nd line:

Please also note to maintain the indented wrapping of this line of code which wraps to 2 lines.

var oResult = oEvaluator.evaluate( count(employee/name) , oXmlDom.documentElement,null, XPathResult.BOOLEAN_TYPE, null);

should be:

var oResult = oEvaluator.evaluate( count(employee/name) , oXmlDom.documentElement,null, XPathResult.NUMBER_TYPE, null);
3/16/06

518Error in Text
Next to last text paragraph, 1st line:

Next you create the SOAPCall
should be:
Next you call the SOAPCall
5/30/05

518Error in Code Block
Jast code block on page. first line:

oSOAPCall.encode

should be:

oSoapCall.encode
5/30/05

585Error in 3rd Code Block
3rd code block. last line (only shaded line in the 3rd code block), this is the last code line before the unroll your loops heading:

} while (i-- >= 0);
should be:
} while (--i >= 0);
12/27/05