Javascript Comment Syntax | Explained

Javascript Comment Syntax

In this article, we will see what is javascript comment and what is the syntax.

What are the comments in JS?

Comments are used to explain code logic. Comments are something like notes in the code. Javascript comment syntax is very easier than HTML comments. So that we can understand the code later as well as other developers can also read and understand the code easily. Comments are used to increase the readability and understandability of the source code. Remember that Comments are ignored by the Javascript engine.

Two types of comments in Javascript :

Single Line comment (// comment goes here)

Anything written after “//” pair of forward slash symbol is treated as single line comment


var a=10; // variable a is created

Multiline comment (/* comment goes here */):

Anything is written in between /*forward slash star sign and */ star forward slash sign is treated as multiline comments.


/* comments are write here */

Example code

<script types"text/Jevescript">

// document is a bullt in Javascript object

document is built in javascript object
write is a method part of document object

document write("Hello Worldt <br/>");
document write("Helle Wor}d2 <br/>");


Leave a Reply