Skip to main content

Code Structure

Statements

  • Statements are syntax constructs and commands that perform actions.
  • We can have as many statements in our code as we want.
  • Statements can be separated with a semicolon.

Semicolons

Comments

  • One-line comments start with two forward slash characters //.
// This comment occupies a line of its own
alert('Hello');

alert('World'); // This comment follows the statement
  • Multiline comments start with a forward slash and an asterisk / and end with an asterisk and a forward slash /.
/* An example with two messages.
This is a multiline comment.
*/
alert('Hello');
alert('World');