Stay Tuned!

Subscribe to our newsletter to get our newest articles instantly!

JavaScript

JavaScript – Comments and Syntax

Comments and Syntax

Comments in JavaScript

  • Normally in JavaScript, the comments are treated as text between //.
  • Multiple line comments are treated as the text between /* and */
  • Comments are required to make code understandable, we don’t have to think we are not only the coder, programmer & expert.
  • If another engineer or developer check any part of the code then S/He should know what is that code and why that code exists. So it’s better to put comments while doing the coding.

HTML / JS Code For Single Line Comment

<html>
 <head>
 </head>
 <body>
  <script language="javascript" type="text/javascript">
  document.write("Hello World!!"); //prints the hello world!!
  </script>
 </body>
</html>

Output

This means that there will not be any change in the output using the comments.

HTML /JS Code For Multiple Line Comment

<html>
 <head>
 </head>
 <body>
  <script language="javascript" type="text/javascript">
  document.write("Hello World!!"); /* prints the
hello world!! program */
  </script>
 </body>
</html>

Output

Again the output remains the same while using multiple line comments in JavaScript.

Avatar

Tuts

About Author

Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.

You may also like

javascript
JavaScript

JavaScript – Introduction, History, and Syntax

  • September 17, 2020
What is “JavaScript”? The first appearance of JavaScript was made in Netscape 2.0 in 1995 with a name Live Script.
javascript
JavaScript

JavaScript – Write Program to Print Hello World!!!

  • September 17, 2020
JavaScript is scripting language which is similar to C. It is syntax and logic are similar to C, C++ and