[Chapter 2] 2.3 Optional Semicolons
Author: David Flanagan
Date: Fri Aug 29 10:49:03 1997

#

| Chapter 2 Lexical Structure |

## 2.3 Optional Semicolons

Simple statements in JavaScript are generally followed by a semicolon character, just as they are in C, C++, and Java. This serves to separate them from the following statement. In JavaScript, however, you are allowed to omit this semicolon if your statements are each placed on a separate line. For example, the following code could be written without semicolons:

    a = 3;
    b = 4;

But when formatted as follows, the semicolons are required:

    a = 3; b = 4;

Omitting semicolons is not a good programming practice; you should get in the habit of using them.

Whitespace and Line Breaks |  | Comments