Comments

Comments can be used to document code. A comment is text that is not executed.

Single-line comments start with two slashes (//). These comments can go on a line by themselves or they can go directly after a line of code.

// This is a comment on a single line.
// Another comment line that is not executed.

let x = 1  // Here is another comment after a line of code.

Multi-line comments start with a slash and an asterisk (/*) and end with an asterisk and a slash (*/):

/* This is a comment which
spans multiple lines. */

Comments may be nested.

/* /* this */ is a valid comment */

Multi-line comments are balanced.

/* this is a // comment up to here */ this is not part of the comment */

Last updated