Navbar

Friday 21 June 2019

Comment in JavaScript

Comment in JavaScript
Javascript comment is meaningful way to deliver message.It means if you are working with huge project then you can put the comment for your own understanding.

Comment are basically used to describe the particular model or unit.Specified comment are not displayed on web browser.It is ignored by Javascript engine i.e Embedded in the browser.

Advantages of Comment :
  1. To make code easy to understand means which code performing what.
  2. Sometimes we put the code which are not useful at certain time then better to put that code in comment section.
Different Types of Comment :
  1. Single-line Comment : For comment single line.
  2. Multi-line Comment : For comment multiple line of code or description.

Single-line Comment
If you want to comment single line of code or description you can do this as follows : 

  1. <script>  
  2.      // It is single line comment  
  3.       document.write("hello techtalktricks");  
  4. </script> 

Explanation : As you can see there is a single-line comment specified. 
// It is single line comment 
This comment will be ignore on web browser. It means only hello techtalktricks will be display on web browser.Developer use this comment for his own understanding.

Multi-line Comment
If you want to comment multiple line at same time then you can do this as follows : 

  1. <script>  
  2.        /* It is multi line comment.  
  3.            It will not be displayed */  
  4. document.write("example of javascript multiline comment");  
  5. </script>  

Explanation : As you can see there is a multi-line comment specified.
/* It is multi line comment.
It will not be displayed */


Watch Complete video on JavaScript Comment


No comments:

Post a Comment

Share your views after read this post