15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

470<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

<strong>Examples</strong> Highlights<br />

✦ Study the code and operation of Listing 34-2 to see how to use <strong>JavaScript</strong> to<br />

convert characters to character codes and vice versa. Converting ASCII or<br />

Unicode numeric values to their corresponding characters requires the<br />

String.fromCharCode() method of the static String object.<br />

✦ Compare the sequence of steps for the string.indexOf() and<br />

string.lastIndexOf() methods to grasp fully the behavior of each and the<br />

differences between them.<br />

✦ Listing 34-4 lets you experiment with the string.replace() and<br />

string.search() methods, both of which utilize regular expression powers<br />

available in <strong>JavaScript</strong> 1.2 of NN4+ and IE4+. Notice how the script functions<br />

assemble the regular expression objects with global modifiers.<br />

✦ Walk through the steps of the string.split() method example to convert a<br />

string to an array.<br />

✦ Compare the behaviors and coding of Listings 34-6 and 34-7 to distinguish the<br />

subtle differences between the string.substr() and string.substring()<br />

methods.<br />

✦ Study the example for string.toLowerCase() and string.toUpperCase()<br />

to see how to remove case sensitivity issues for some operations.<br />

✦ Convert a long floating-point number to a dollars-and-cents string by following<br />

the steps for the number.toFixed() method.<br />

String Object<br />

Properties<br />

constructor<br />

stringObject.constructor<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓ ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to test the value of the<br />

constructor property. Enter the following statements into the top text box:<br />

a = new String(“abcd”)<br />

a.constructor == String<br />

a.constructor == Number

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!