JavaScript Comment


Prev Tutorial Next Tutorial

Comment in JavaScript

Comment is nothing but it is a statement which is not display on browser window. it is useful to understand the which code is written for what purpose.

Comments are useful in every programming language to deliver message. It is used to add information about the code, warnings or suggestions so that the end user or other developer can easily interpret the code.

Types of JavaScript Comments

There are two types of comments are in JavaScript

  • Single-line Comment
  • Multi-line Comment

Single-line Comment

It is represented by double forward slashes //. It can be used before any statement.

Example JavaScript Comment

<script>  
// It is single line comment  
document.write("Hello Javascript");  
</script>  

Result

Multi-line Comment

It can be used to add single as well as multi line comments.
It is represented by forward slash / with asterisk * then asterisk with forward slash.

Example JavaScript Comment

<script>  
/* It is multi line comment.  
It will not be displayed */  
document.write("Javascript multiline comment");  
</script>  

Result


Prev Tutorial Next Tutorial

Advertisements




Download Projects