Comments

Contents

1.3. Comments#

In the rest of this module we will use comments to help explain the code so let’s look at how they work.

JavaScript supports two types of comments: single-line comments and multi-line comments. Comments allow you to add notes or explanations to your code that are ignored when the program runs.

Single-Line Comments

These comments start with // and anything after that point is treated as a comment.

// This is a single-line comment
let age = 16; // This comment explains the variable

Multi-Line Comments

These comments start with /* and end with */. They can span as many lines as you like.

/*
This is a multi-line comment.
It can explain a more complex piece of code.
*/

let person = "Alice";

1.3.1. Glossary#

Comment#

A comment is a note or explanation in code that is ignored when the program runs.

Single-line comment#

A single-line comment starts with // and continues to the end of that line.

Multi-line comment#

A multi-line comment starts with /* and ends with */, allowing a comment to span several lines.