Summary of JavaScript Statements
This chapter introduced each of the JavaScript language’s statements. Table 5-1 summarizes them, listing the syntax and purpose of each.
Table 5-1. JavaScript statement syntax
| Statement | Syntax | Purpose |
|---|---|---|
| break | break
[ | Exit from the innermost loop or |
| case | case
| Label a statement within a |
| continue | continue
[ | Begin next iteration of the innermost loop or the named loop |
| debugger | debugger; | Debugger breakpoint |
| 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
( | Enumerate the properties of
|
| function | function
| Declare a function named
|
| if/else | if
( | Execute |
| label | | Give |
| return | return
[ | Return a value from a function |
| switch | switch
( | Multiway branch to |
| throw | throw
| Throw an exception |
| try | | Handle exceptions |
| use strict | "use
strict"; | Apply strict mode restrictions to script or function |
| var | var
| Declare and initialize one or more variables |
| while | while
( | A basic loop construct |
| with | with
( |