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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

{<br />

}<br />

if (j == 3)<br />

continue outerloop;<br />

document.write("Innerloop: "+j+"");<br />

document.write("All loops done"+"");<br />

<strong>The</strong> script‘s output with and without the labeled continue statement is shown in Figure 4-4.<br />

Figure 4-4: continue used both with and without the label<br />

Labels stop short of providing the flow control of the notorious goto statement, despised by<br />

many programmers. However, don‘t be too surprised if eventually such a statement is<br />

introduced into <strong>JavaScript</strong>, especially considering that it is already a reserved word (see<br />

Appendix C).<br />

Object-Related Statements<br />

<strong>The</strong> final group of statements to cover is related to the use of objects. A brief introduction to<br />

these statements is presented here, while a full-blown discussion of the use of these<br />

statements as well as of keywords such as this is reserved primarily for Chapter 6.<br />

with Statement<br />

<strong>JavaScript</strong>‘s with statement allows programmers to use a shorthand notation when referencing<br />

objects. For example, normally to write to an (X)HTML document, we would use the write()<br />

method of the Document object:<br />

document.write("Hello from <strong>JavaScript</strong>");<br />

document.write("");<br />

document.write("You can write what you like here");

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

Saved successfully!

Ooh no, something went wrong!