How to do multi line comment in JavaScript

I want to do multi line comment in my code. Which symbol is used for it?


13 Answers
1-13 of  13
13 Answers
  • Multi-line comment in JavaScript: Use /* */ symbols. Example: /* This is a multi-line comment */ Simple as wrapping your words inside a quiet box 🤫

  • In JavaScript, multi-line comments are written using: JavaScript /* This is a multi-line comment */

  • JavaScript, multi-line comments are written using /* */
    Example:
    JavaScript
    /*
    This is a multi-line comment
    It can span multiple lines
    */
    👉 Everything inside /* and */ is ignored by JavaScript.

  • Multiline comments are used for large text descriptions of code or to comment out chunks of code while debugging applications. Comments are ignored by the compiler.

    Multi-line comments, are long-form annotations used to introduce and explain a section of code. Often these types of comments are placed at the top of a file, or before a particularly complex code block.
    exp: greet.js
    /* Initialize and invoke a the greetUser function to assign user's name to a constant and print out a greeting. */ function greetUser() { const name = prompt("What is your name?"); console.log("Hello ," + name + "! How are you?"); } greetUser();

    You may also sometimes see a slightly modified version of the block comment syntax, which starts with /** and includes asterisks throughout the left side of comment block.

  • JavaScript supports three different types of comments:
    Multiple-line C-style comments. Everything between /* and */ is a comment, for example:
    /* This is a comment */ /* C-style comments can span as many lines as you like, as shown in this example */
    One-line comments of C++ style. These comments begin with // and continue up to the next line break:
    // This is a one-line comment
    One-line comments with the HTML comment-opening sequence (<!--). Note that the JavaScript interpreter ignores the closing characters of HTML comments (-->). Consider this example:
    <!-- This is treated as a one-line JS comment <!-- It works just like a comment beginning with // <!-- --> This is also a one-line JS comment <!-- --> because JS ignores the closing characters <!-- --> of HTML-style comments
    HTML-style comments are not usually found in the middle of JavaScript code. 

  • /*lines to be commented or code block */ // line to be commented

  • For multi line comment in JavaScript the comment is written between /* */

    For an example

    /*
    This is the comment in JavaScript.
    Here the program ends.
    */

  • if you want to give multi line comment in JavaScript then you must use
    /*
    ......
    the code which you want to comment
    finishing the comment with
    ........
    */

  • /*......Comments.
    ..
    .....*/
    //single line comment

  • Use Syntax
    for multiple lines
    /*
    Comments
    */
    for single line 
    // comments

    used for documentation
    /*docs
    *docs
    *mthods
    *vars
    *comments
    */

  • /* .........*/

  • /* xxxxxxxxxxxxx
    xxxxxxxxxxx
    xxxxxxx
    xxxxxxx */
    shortcut for this generally depends on your code editor

Javascript

Didn't get the answer.
Contact people of Talent-Javascript directly by clicking here