Comment is the description of the code and used to prevent the execution of a code block. It’s one of the first things coder have to learn. It is used to make the code more readable. It's important best practices when writing code. All professional code should have comments. It is not easy to understant the logic behind the code without comments.
Single-line comments are typically used to document short description that fit on a single line. This style comment start with
// followed by the description.
// This is a single-line comment.
var is_expired = false; // set to true when expired.
//Following code will show the dialog box to say hello.
Multi-line comments are typically used to document major functions or code blocks. This style comment start with
/* and end with
/* This is multi-line comments */
* This is comment line one.
* This is comment line two.
* Following code will show the dialog box to say hello.
* "name" is the name of the person who you want to say hello.
alert("Hello " + name);
Both comment styles may be mixed in same program but should never be nested.
blog comments powered by