2.3 Whitespace and Line Breaks
JavaScript
ignores spaces,
tabs, and newlines that appear between tokens in programs,
except those that are part of string or regular expression literals.
A token is a keyword, variable name, number,
function name, or some other entity in which you would obviously not
want to insert a space or a line break. If you place a space, tab, or
newline within a token, you break it up into two tokens -- thus,
123 is a single numeric token, but
12 3 is two separate tokens
(and constitutes a syntax error, incidentally).
Because you can use spaces, tabs, and
newlines freely in your programs (except in strings, regular
expressions, and tokens), you are free to format and indent your
programs in a neat and consistent way that makes the code easy to
read and understand. Note, however, that there is one minor
restriction on the placement of line breaks; it is described in the
following section.
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.