course content

Course Content

Introduction to JavaScript

CommentsComments

Sometimes you need a part of your code not to be executed.

You don't want to delete all the code to see the execution of a separate part of the code, it's not convenient. Sometimes it is necessary to stop the execution of the non-working part of the code to finish it later. There are many such situations, and they are all different.

There are comments.

Note

Comments are a syntax for hiding part of the code from the interpreter or compiler. Used to document code for other developers.

Single-line Comments

Single-line comments block the full line of code. The code above and below is executed.

Single-line comments syntax is so simple. You need to add // before the code in line:

This can be used to block multiple lines of code in a row:

Also, you can use it to comment the last part in one line:

Multi-line Comments

Consider a case when we have a lot of code. For example, 299 lines. It will take a long time to comment on each line. That's why there are multi-line comments.

Multi-line comments syntax starts with /* and ends with */. All code inside will be commented:

You can use multi-line comments to comment a part of the line:

1. Single-line comment syntax:
2. Multi-line comment syntax:

question-icon

Single-line comment syntax:

Select the correct answer

question-icon

Multi-line comment syntax:

Select the correct answer

Section 1.

Chapter 4