JavaScript Comments


The programming design is explained in JavaScript comments. If required, they can also be used to prohibit the execution of a part of code. While the compiler is running the code, comments are ignored. Comments are user-friendly because they allow users to acquire code explanations.

Return Value: Comments are ignored during code execution.

You can use comments to add notes or hints to JavaScript code. The JavaScript engine ignores the comments when executing the code.

JavaScript allows for both single-line and block comments.


Single-Line Comments

A single-line remark begins with two forward slashes (/). A single-line comment converts all text after the / on the same line into a comment.

Example

Preview

Block Comments

A delimited comment starts with a forward slash and an asterisk /* and ends with the opposite */.

Example

Preview