What are Comments in JavaScript?

JavascriptWeb DevelopmentFront End Technology

JavaScript supports both C-style and C++-style comments, thus

  • Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript.
  • Any text between the characters /* and */ is treated as a comment. This may span multiple lines.
  • JavaScript also recognizes the HTML comment opening sequence <!--. JavaScript treats this as a single-line comment, just as it does the // comment.
  • The HTML comment closing sequence --> is not recognized by JavaScript so it should be written as //-->.


The following example shows how to use comments in JavaScript.

      // This is a comment. It is similar to comments in C++
            * This is a multiline comment in JavaScript
            * It is very similar to comments in C Programming
Published on 09-Jan-2018 09:27:49