JavaScript Comments For Single Or Multiple Line

In JavaScript, the comments are the Lines or text which helps in reading the programs it is useful information that is non-executable.

Single Line Comments

In JavaScript  the single line Comments are starts from //.

Example:

<!DOCTYPE html>
<html>
<body>
<h1 id="myHeading"></h1>
<p id="myPara"></p>
<script>
// comments:
document.getElementById("myHeading").innerHTML = "Single Line Comments";
// comments:
document.getElementById("myPara").innerHTML = "Welcome to comment guide";
</script>
</body>
</html>

Multiple Line Comments

In JavaScript the multiple line comments are starts with /* & ends with */ and the text between two symbols will ignored and non-executable.

Example:

<!DOCTYPE html>
<html>
<body>
<h1 id="myHeading"></h1>
<p id="myPara"></p>
<script>
/*
Multiple Line comments
*/
document.getElementById("myHeading").innerHTML = "Multiple line Comments";
document.getElementById("myPara").innerHTML = "Hello India";
</script>
</body>
</html>

Stay in touch. Ask Questions.
Lean on us for help, strategies and expertise.

Leave a Reply

Your email address will not be published. Required fields are marked *