Next page | Contents page |

Statements & compound statements

All statements end with a semicolon or a new line. Best practice: always use semicolon.

Warning: be careful - if you fold a statement JavaScript can treat it as 2 statements (unlike C/Java).

Anywhere that a statement could be used it may be replaced by a compound statement, in curly braces:


{
  statement1;
  statement2;
  // ... etc
  
}

Nested compound statements are common.

Next page | Contents page |