Skip to Content
JavaScript: The Definitive Guide, 6th Edition
book

JavaScript: The Definitive Guide, 6th Edition

by David Flanagan
May 2011
Intermediate to advanced
1093 pages
40h 54m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, 6th Edition

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

StatementSyntaxPurpose
breakbreak [label];

Exit from the innermost loop or switch or from named enclosing statement

casecase expression:

Label a statement within a switch

continuecontinue [label];

Begin next iteration of the innermost loop or the named loop

debuggerdebugger;

Debugger breakpoint

defaultdefault:

Label the default statement within a switch

do/whiledo statement while (expression);

An alternative to the while loop

empty;

Do nothing

forfor(init; test; incr) statement

An easy-to-use loop

for/infor (var in object) statement

Enumerate the properties of object

functionfunction name([param[,...]]) { body }

Declare a function named name

if/elseif (expr) statement1 [else statement2]

Execute statement1 or statement2

labellabel: statement

Give statement the name label

returnreturn [expression];

Return a value from a function

switchswitch (expression) { statements }

Multiway branch to case or default: labels

throwthrow expression;

Throw an exception

try

try { statements }

[catch { handler statements }]

[finally { cleanup statements }]

Handle exceptions

use strict"use strict";

Apply strict mode restrictions to script or function

varvar name [ = expr] [ ,... ];

Declare and initialize one or more variables

whilewhile (expression) statement

A basic loop construct

with with (
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: The Definitive Guide, 5th Edition

JavaScript: The Definitive Guide, 5th Edition

David Flanagan

Publisher Resources

ISBN: 9781449393854Errata PageSupplemental Content