MEPX
Chapter 2 of 16All chapters

Chapter 2 of 16

Syntax and statements

Semicolons, blocks and strict mode.

Shape of a program

Statements end with a semicolon, which the engine will insert for you if you leave it out. That mostly works, and the exceptions are annoying enough that most teams either always write them or run a formatter.

  • Braces group statements into a block, and blocks matter for let and const.
  • Comments are // to end of line and /* ... */ across lines.

Strict mode and modules

Modules and class bodies run in strict mode automatically, which turns silent mistakes into errors. In an old script you can opt in by putting "use strict" at the top.