Loading Please Wait...

Logo Lynxsia IT Solutions

JavaScript Comments

JS Comments

JavaScript comments can be used to describe the working of the JavaScript code, and to make it more readable.

When testing and debugging the JavaScript code, JavaScript comments can be used to prevent the execution.

Single Line Comments

Single line comments start with //.

Any text between // and the end of the line will be ignored by JavaScript and will not be executed.

					 
        
          // Change heading:
          document.getElementById("heading").innerHTML = "This is heading";

          // Change paragraph:
          document.getElementById("paragraph").innerHTML = "This is paragraph.";

          let a = 10;      // Declare a, give it the value of 10
          let b = a + 5;  // Declare b, give it the value of a + 5
        
      
Multi Line Comments

Multi line comments (or Block Comments) start with /* and end with */.

Any text between /* and */ will be ignored by JavaScript.

Block comments are often used for formal documentation.

					 
        
          /*
            The code below will change
            the heading with id = "heading"
            and the paragraph with id = "paragraph"
            in the web page:
          */
          document.getElementById("heading").innerHTML = "This is heading";
          document.getElementById("paragraph").innerHTML = "This is paragraph.";
        
      
Using Comments to Prevent Execution

Using comments to prevent execution of code is suitable for code testing.

					 
        
          // document.getElementById("heading").innerHTML = "This is heading";
          document.getElementById("paragraph").innerHTML = "This is paragraph.";

          /*
            document.getElementById("heading").innerHTML = "This is heading";
            document.getElementById("paragraph").innerHTML = "This is paragraph.";
          */
        
      

How you feel about this blog:

Share this blog on:

Report Us

If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com

Contact Us
Ads
Logo
Lynxsia IT Solutions

We are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..

Kotwali Road, Chhiptehri, Banda, 210001, UP, India

Copyright © 2022, Lynxsia IT Solutions, All rights reserved