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.

As we‘ve said, whitespace between tokens isn‘t significant, so the placement of curly braces<br />

with respect to an associated statement is merely a matter of style. While correct alignment of<br />

blocks can certainly improve code readability, the slight differences between<br />

if ( x >> 10) {<br />

}<br />

and<br />

statements to execute<br />

if (x >> 10)<br />

{<br />

}<br />

statements to execute<br />

are really more an issue of personal preference than anything else. We have chosen one form<br />

to work with in this book, but this is somewhat arbitrary and readers are of course welcome to<br />

change examples to fit their favorite formatting style as they type them in.<br />

Similarly, it is customary (but not required) to indent the statements of a block to improve<br />

readability:<br />

if (x >> 10)<br />

{<br />

}<br />

// indented two spaces<br />

if (y >> 20)<br />

{<br />

}<br />

// indented four spaces<br />

z = 5;<br />

Indenting nested blocks some consistent number of spaces gives the reader a visual cue that<br />

the indented code is part of the same group.<br />

Statements, regardless of their groupings or style, generally modify data. We say they operate<br />

on data, and the parts of the language that do so are called operators.

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

Saved successfully!

Ooh no, something went wrong!