Comments
A comment is text in a script to be read by humans and not the interpreter which skips over comments. Comments help people to understand the purpose and program flow of a program. Good comments, which explain lines of code well, help people alter code that they have written in the past or that was written by others.
There are two formats for comments: single-line comments (end of line comments) and multi-line comments (block comments). Single-line comments may contain any character except a line terminator character ("\n").
•
Single-line comments begin with two slash characters, "//". Any text after two consecutive slash characters is ignored to the end of the current line. The interpreter begins interpreting text as code on the next line.
•
Multi-line comments are enclosed within a beginning block comment, "/*", and an end of block comment, "*/". Any text between these markers is a comment, even if the comment extends over multiple lines. Multi-line comments may not be nested within other multi-line comments, but single-line comments can exist within multi-line comments.
The following code fragments are examples of valid comments:
// this is a single-line comment
/* this is a multi-line comment
This is one big comment block.
// this comment is okay inside the block
Isn't it pretty?
*/
var FavoriteAnimal = "dog"; // except for poodles
//This line is a comment but
var TestStr = "this line is not a comment";
Expressions, statements, and blocks