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.

Description

The block statement is often called compound statement in other languages. It allows you to use multiple statements where JavaScript expects only one statement. Combining statements into blocks is a common practice in JavaScript. The opposite behavior is possible using an empty statement, where you provide no statement, although one is required.

Blocks are commonly used in association with if...else and for statements.