Skip to Content
JavaScript: The Definitive Guide, Fourth Edition
book

JavaScript: The Definitive Guide, Fourth Edition

by David Flanagan
November 2001
Intermediate to advanced
936 pages
68h 43m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, Fourth Edition

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 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 [ ...
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.
Start your free trial

You might also like

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

John Pollock
JavaScript Cookbook, 3rd Edition

JavaScript Cookbook, 3rd Edition

Adam D. Scott, Matthew MacDonald, Shelley Powers

Publisher Resources

ISBN: 0596000480Supplemental ContentCatalog PageErrata