6.20 Summary of JavaScript Statements
This chapter introduced each of the statements of the JavaScript
language. Table 6-1 summarizes these
statements, listing the syntax and purpose
of each.
Statement | Syntax | Purpose |
|---|---|---|
break | break; break labelname; | Exit from the innermost loop or switch statement or from the statement named by label. |
case | case expression: | Label a statement within a switch statement. |
continue | continue; continue labelname; | Restart the innermost loop or the loop named by label. |
default | default: | Label the default statement within a switch statement. |
do/while | do statement while (expression); | An alternative to the while loop. |
empty | ; | Do nothing. |
for | for (initialize ; test ; increment) statement | An easy-to-use loop. |
for/in | for (variable in object) statement | Loop through the properties of an object. |
function | function funcname([arg1[..., argn]]) { statements } | Declare a function. |
if/else | if (expression) statement1 [else statement2] | Conditionally execute code. |
label | identifier: statement | Give statement the name identifier. |
return | return [expression]; | Return from a function or return the value of expression from a function. |
switch | switch (expression) { statements } | Multiway branch to statements labeled with case or default: . |
throw | throw expression; | Throw an exception. |
try | try { statements } catch (identifier) { statements } finally { statements } | Catch an exception. |
var | var name_1 [ = value_1] [ ..., name_n [ = value_n]]; | Declare and initialize variables. |
while | while (expression) statement | A basic loop construct. |
with | with (object) statement | Extend the scope chain. (Deprecated.) |
•
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.