Javascript Comment

A comment is a comment that is added to a program file or code snippet during program writing. Annotating can improve code readability, allowing yourself or other developers to understand the program more quickly.

JavaScript annotations are not part of a JavaScript program and their content does not participate in any function calculations in the program and is displayed in a special color (such as green) in the editor.

JavaScript comment symbols

JavaScript comments are divided into single-line comments and multi-line comments of two.

JavaScript single-line comments

Single-line comment symbol is //, the symbol is the contents of the Notes until the end of the line. The following is an example of a comment:

// Here is a pop-up message box
alert("I am prompted text");

JavaScript multiline comments

Multi-line comments can be annotated with multiple lines of code at once, with multiple lines beginning with / * and ending with * /. Here's an example of a multi-line comment:

   The following is a pop-up prompt message box in the line of code, 
   without any variables or parameters
alert("I was prompted text");

Note that the content is not only some explanatory text, it can be some unused code fragments, to prohibit the implementation of these codes.

Obviously, it is more convenient to use a double-slash single-line comment for a small number of comments that span one or several lines. It is easier to use multi-line comments for large amounts of comments, especially for large pieces of code that are not needed temporarily.

Copyright 2014-2017 by All Rights Reserved.