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.
Table 6-1. JavaScript statement syntax
|
Statement |
Syntax |
Purpose |
|---|---|---|
break |
break;
break
|
Exit from the innermost loop or |
case |
case
|
Label a statement within a |
continue |
continue;
continue
|
Restart the innermost loop or the loop named by
|
default |
default: |
Label the default statement within a |
do/while |
do
|
An alternative to the |
empty |
; |
Do nothing. |
for |
for ( |
An easy-to-use loop. |
for/in |
for ( |
Loop through the properties of an object. |
function |
function |
Declare a function. |
if/else |
if ( |
Conditionally execute code. |
label |
|
Give |
return |
return [
|
Return from a function or return the value of
|
switch |
switch ( |
Multiway branch to statements labeled with |
throw |
throw
|
Throw an exception. |
try |
try {
|
Catch an exception. |
var |
var |