We can use comments in programming language to make program more readable and use comment to provide additional information to a piece of code or about the functionality of code. In java script there is two types of comments.

  •    Single Line Comment
  •    Multiline Comment

We can use single line comment to comment only one line in java script and we can use multi line comment to comment multiple line concurrently. We can use any where comment in our program according to requirement. It is good practice to use comments in your program. Comments are ignored by compiler or interpreter when they are executed.

The following demonstration shows the use of comments in program.
functioncommentDemo() {
                This program is developed by Awadhendra Tiwari and is used to demonstrate
                multiline and single line comments in java script. Multiline comments are
                started by forword slash followed by * followd by multiple statements then
                followd by * followed by farword slash.
            document.write("<h2>This is a sample application which demonstrate use of document.write() method in java script</h2><br />");
            document.write("Creating order list.<br /><font face='times new roman' size='5' color='green'>");
            document.write("<ol type='i'>"); //This is a demonstration of single line comment.
            document.write("<li>Hello world.");//Single line comments are started by double forward slash.
            document.write("<li>It is a fantastic show.");

Always remember that comments are not part of the program output.

  Modified On Nov-30-2017 04:21:23 AM

Leave Comment