Close Menu
    Facebook X (Twitter) Instagram
    Oixiesoft
    • Home
    • Services
      • WordPress Malware Removal
      • Fix WordPress Errors
      • WordPress Website Development
    • Articles
    • Contact
    Oixiesoft
    Home»Tutorial»JS»JS Comments
    JS

    JS Comments

    Editorial StaffBy Editorial StaffUpdated:May 14, 2022No Comments2 Mins Read
    Share
    Facebook Twitter LinkedIn Pinterest Email

    JavaScript comments

    Developers use JavaScript comments to explain their JavaScript code not only to themselves but also to other fellow developers. It is a good practice to write comments as you code.

    With the help of JavaScript comments, we can be preventing execution when testing alternative code.

    Example: Commenting all code

    
    // The code below won't execute, as it is marked as a comment, preventing its execution
    
    // var num3 = 5 + 6;

    Single line comments

    Single line comments start with //.

    Example

    
    // This is a single line comment
    
    var num1 = 1 + 2;
    
    var num2 = 3 + 4; // This is an inline comment

    Multi-line comments

    Multi-line comments start with /* and end with */.

    Example: 1

    
    /*
    
    When you have a lot to explain,
    
    use multi-line comments
    
    like this
    
    */
    
    var num4 = 7 + 8;

    Example: 2

    
    <!DOCTYPE html>
    <html>
    <body>
    
    <h2>JavaScript multi-line comments Example</h2>
    
    <p> a, b, and c are variables.</p>
    
    <p id="test"></p>
    
    <script>
    var a = 7;
    var b = 10;
    var c = a + b;
    
    /* where a, b, and c, are three variables
    
    and declared these variables with the var keyword.
    */
    
    document.getElementById("test").innerHTML =
    "The value of c is: " + c;
    </script>
    
    </body>
    </html>
    Share. Facebook Twitter Pinterest LinkedIn WhatsApp Reddit Tumblr Email
    Editorial Staff

    Related Posts

    CodeIgniter vs Laravel: A Detailed Side-by-Side Comparison

    Python Arrays

    Python Lambda

    Services
    • Web Development
    • Mobile Application Development
    • WordPress Malware Removal Service
    • Website Design
    • WordPress Development
    • Magento Development
    • Shopify Development
    • SEO Services
    Blog
    • How to Fix the Error Establishing a Database Connection
    • Ping List WordPress
    • How To Fix Japanese Keyword Hack
    • How to remove Malware from WordPress
    Hire Developers
    • Hire WordPress Developer
    • Hire Shopify Developer
    Contact Info
    • Oixiesoft Technologies
      A-40, Block A, I thum Tower, Sector 62, Noida
    • [email protected]
    • Privacy Policy
    • About Us
    • Contact Us
    © 2025 OixieSoft Technologies

    Type above and press Enter to search. Press Esc to cancel.