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 |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access