User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

When writing code you may have some complex logic that is confusing. This is a perfect opportunity to include some comments in the code that will explain what is going on. Not only will this help you remember it later on, but someone else views your code, they will also be able to understand the code.

Another great thing about comments is the ability to comments to remove bits of code from execution when you are debugging your scripts. This lesson will teach you how to create two types of comments in JavaScript:

Single line comments and Multi-line comments.

Creating Single line comments:

To create a single line comment in JavaScript, you place two slashes "//" in front of the code. When you place these two slashes, all text to the right of them will be ignored, until the next line.

Example:

 <html>
<body>
<script>
//This is a Single line comment
document.write("<h1>Mindphp.com</h1>");
//This is another Single line comment
</script>
</body>
</html>

This is the result:

 

Creating Multi-line comments:

 Although a single line comment is quite useful, it can sometimes be burdensome to use when disabling long segments of code or inserting long-winded comment. For this large comments you can use JavaScript's multi-line comment that begin with /* and end with */

Example:

<html>
<body>
<script>
/*This is a comment
This is a comment
This is a comment
*/
document.write("<h1>JavaScript</h1>");
</script>
</body>
</html>

This is the result:

 

 

Next

Chapter 6 - JavaScript Variables

 

Recent Topics
Subject
Post Reply
Open
Recent
Plugin System MZC Auto Close to enable the open and close odering system
By prmindphp Wed 19 Feb 2020 6:38 pm Board English Language
0
12
Wed 19 Feb 2020 6:38 pm By prmindphp
MDPartner Component for store client data in CRM system
By prmindphp Sat 25 Jan 2020 3:04 pm Board English Language
0
58
Sat 25 Jan 2020 3:04 pm By prmindphp
i am looking for help
By Anonymous Tue 14 Jan 2020 5:46 pm Board English Language
1
73
Tue 14 Jan 2020 6:03 pm By noppadonsk
Dot Net Training
By Poonaam Fri 10 Jan 2020 2:20 pm Board English Language
0
84
Fri 10 Jan 2020 2:20 pm By Poonaam
MDRental, Area management assistant for rental business
By prmindphp Wed 08 Jan 2020 6:51 pm Board English Language
0
58
Wed 08 Jan 2020 6:51 pm By prmindphp
Fix Gmail Error 404 By Taking Gmail Help Quickly
By Anonymous Wed 08 Jan 2020 2:56 pm Board English Language
0
52
Wed 08 Jan 2020 2:56 pm By Anonymous
How To Add New Facebook Friends using Facebook Phone Number?
By Anonymous Tue 07 Jan 2020 4:20 pm Board English Language
0
53
Tue 07 Jan 2020 4:20 pm By Anonymous
DBA Training Institute
By Shrutiii Wed 01 Jan 2020 3:06 pm Board English Language
0
59
Wed 01 Jan 2020 3:06 pm By Shrutiii
Tools for calculating the withholding tax easily reduce large tax
By prmindphp Wed 25 Dec 2019 6:56 pm Board English Language
0
59
Wed 25 Dec 2019 6:56 pm By prmindphp
Helper to calculate interest rates for investors
By prmindphp Tue 24 Dec 2019 6:52 pm Board English Language
0
110
Tue 24 Dec 2019 6:52 pm By prmindphp
Plan your savings easily with FV (Future Value) Calculator
By prmindphp Mon 23 Dec 2019 7:28 pm Board English Language
0
64
Mon 23 Dec 2019 7:28 pm By prmindphp
Payment Calculator, Installment calculation to make decisions
By prmindphp Fri 20 Dec 2019 6:00 pm Board English Language
0
74
Fri 20 Dec 2019 6:00 pm By prmindphp
Program Calculate Home Loan, Tools that will help you calculate home loans easily and quickly
By prmindphp Thu 19 Dec 2019 6:59 pm Board English Language
0
77
Thu 19 Dec 2019 6:59 pm By prmindphp
The website loads slowly ? The image size is not proportional, MImageoptimize Plugin of Joomla can help
By prmindphp Tue 17 Dec 2019 7:05 pm Board English Language
0
79
Tue 17 Dec 2019 7:05 pm By prmindphp
Calculation program Number of Periods (NPER)
By prmindphp Mon 16 Dec 2019 7:21 pm Board English Language
0
131
Mon 16 Dec 2019 7:21 pm By prmindphp
Calculation program after including VAT
By prmindphp Fri 13 Dec 2019 5:32 pm Board English Language
0
310
Fri 13 Dec 2019 5:32 pm By prmindphp
Plugin Content MChangelog ,helps add content that has changed, update, and fix the problem
By prmindphp Thu 12 Dec 2019 6:46 pm Board English Language
0
150
Thu 12 Dec 2019 6:46 pm By prmindphp
Pace Calculator
By prmindphp Wed 11 Dec 2019 6:53 pm Board English Language
0
116
Wed 11 Dec 2019 6:53 pm By prmindphp
Introducing to MooZiiCart's Coupons feature, create coupons on website sell products online it is certain to boost sales
By prmindphp Mon 09 Dec 2019 11:06 am Board English Language
0
95
Mon 09 Dec 2019 11:06 am By prmindphp
Introducing to MooZii Opencart - Template MooZiicart create a beautiful website by yourself
By prmindphp Fri 06 Dec 2019 10:47 am Board English Language
0
117
Fri 06 Dec 2019 10:47 am By prmindphp