Block Statements

JavaScript has "statement blocks" that combine multiple lines into a compound statement. Block statements are enclosed in curly brackets { } and do not require an ending semicolon. We'll use block statements when writing conditional statements in Unit 4.

Syntax

Block Statement

{
  StatementList
}


Labelled Block Statement

LabelIdentifier: {
  StatementList
}


StatementList

Statements grouped within the block statement.

LabelIdentifier

An optional label for visual identification or as a target for break.