11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

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.

<br />

<br />

<br />

<br />

document.write("This text is not followed by a linebreak. ");<br />

document.writeln("However this uses writeln().");<br />

document.write("So a newline was inserted.");<br />

<br />

<br />

<br />

<br />

<strong>The</strong> result of this example in a browser window can be seen in Figure 2-1.<br />

Figure 2-1: Output of write() and writeln() methods<br />

In addition to write() and writeln(), the Document object provides powerful features for<br />

manipulation of HTML and XML via the Document Object Model. <strong>The</strong> DOM, which is covered<br />

primarily in Chapter 10, can be used to replace or insert text, change formatting characteristics,<br />

and write to or read from HTML forms.<br />

Regular Expressions<br />

<strong>The</strong> last major functional feature of <strong>JavaScript</strong> is the regular expression. A regular expression<br />

as defined by the RegExp constructor is used to carry out pattern matching.<br />

var country = new RegExp("England");<br />

This could have been defined as well using a direct assignment:

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

Saved successfully!

Ooh no, something went wrong!