Pilcrow Records

Scripter Javascript Tutorial

javascriptmusiclogicscripterbookexcerpttutorial

6 Semicolons

MDN: Grammar and types: Basics

Semicolons separate statements from each other. In the above example, there are two statements, one on each line, each ending with a semicolon. Modern JavaScript and also Scripter, no longer requires semicolons when a line break exists. This example is just as valid as the original:

var say_hello = "Hello, world!"
Trace(say_hello)

There are other rules regarding when to use semicolons, which will be addressed in other parts of this tutorial. Whether or not to use semicolons is as much a matter style as anything. Removing the semicolon requirement is a relatively recent change to the language. All of the examples in this book will use the semicolon at the end of statements for clarity and consistency.