JavaScript Syntax

The syntax of JavaScript refers to the rules that you must follow as you code statements. If you don't adhere to these rules, your web browser won't be able to interpret and execute your statements.

  1. JavaScript is case-sensitive.
  2. JavaScript ignores extra whitespace within statements.
  3. Each JavaScript statement ends in a semicolon.

How to split a statement over two or more lines:

  • After an arithmetic or relational operator such as +,-,*,/,=,or ==.
  • An opening brace, bracket or parenthesis.
  • A closing brace.

Do not split a statement after:

  • An identifier, a value or the return keyword.
  • A closing bracket or parenthesis because JavaScript will try to correct what it thinks is a missing semicolon by adding a semicolon at the end of a split line.