Part 2.2Comments in JavaScript

Very few programming languages do not support comments. Comments are useful ways of adding contextual information about a piece of code in a program.

JavaScript comments

JavaScript features comments too. In JavaScript a comment is signified by either of the following two symbols:

  • //
  • /* */

The difference between these two types of comments is that the first version only works across a single line:

JavaScript
//This is a comment

The second version can span multiple lines:

JavaScript
/* This is a comment
 * This is also a comment
*/

It is often the case to use an asterisk on each line between the opening and closing comment tags as shown on line 2 previously but it is not completely necessary.

Feedback 👍
Comments are sent via email to me.