JavaScript supports a compact set of statements, specifically control flow statements, that you can use to incorporate a great deal of interactivity in your application. This chapter provides an overview of these statements.

The JavaScript reference contains exhaustive details about the statements in this chapter. The semicolon (;) character is used to separate statements in JavaScript code.

Any JavaScript expression is also a statement. See Expressions and operators for complete information about expressions.

Block statement

The most basic statement is a block statement, which is used to group statements. The block is delimited by a pair of curly brackets:

{
  statement1;
  statement2;
  // …
  statementN;
}

Example

Block statements are commonly used with control flow statements (ifforwhile).

while (x < 10) {
  x++;
}