X



Home>Tutorial>

Understanding What is JavaScript Single Line Comments and JavaScript Multiline Comment With Example

Nuelson Penuel Thursday, August 12, 2021 Javascript

Introduction

Every program or application needs a good programmer documentation for any software developer that have access to understand what each line of code does. Also understanding how to insert JavaScript comment or how to insert a comment that has more than one line is very important. With comment, you can be able to tell the viewer of your source code what it is all about. In this brief post, you will learn how to use JavaScript single line comment and JavaScript multiline comment alongside examples.

What is Comment in JavaScript?

Comment is referred to as non-executable string of characters. It is through comment that codes or script can be explained in such a way that everyone that have access to the source code will have a better understanding and flow of the program.

What are the Different Types of Comments in JavaScript

In JavaScript, we have different types of comments and these are:
  • Singe line comment
  • Multiline comment

What is single line in JavaScript

As the name implies, single line comment applies to a single line in the source code.

JavaScript single line comment syntax

JavaScript single line comment is denoted by: //comment content comes here

What is multiline in JavaScript

Multiline comment as it implies applies to more than one line in the source code.

JavaScript multiline comment syntax

The JavaScript multiline comment is denoted by: /* comment content goes here */

What are the Advantages of JavaScript comments

The advantages of comments in web development cannot be overemphasized. Some of its advantages are:
  1. It makes codes to be understandable by anyone that view it
  2. It can be used to comment out irrelevant parts of codes.

Examples of JavaScript Comment

Example of javascript multiline comment

Here is a simple demonstration of multiline JavaScript.
<script>
function(){
/*var a;
var b;*/
}
</script>

Example of javascript single comment

Here is a simple demonstration of single line JavaScript.
<script>
function(){
//var a;
//var b;
}
</script>

| | Views(332)

See Demo | Download File


Add your comment. Indicate code using code tag


Words: 0 | Chars: 0 | Reading Duration: 0



Images Attachment




Emmason Integratded Services(2017-2024)
All Rights Reserved
Designed and Maintained By Emmason Integrated Services