Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

The JavaScript FAQ
Prev Home Next

Comments in JavaScript

Question: How do I insert comments in JavaScript code?

Answer: JavaScript supports three different types of comments:

  1. 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 */
    
  2. One-line comments of C++ style. These comments begin with // and continue up to the next line break:
    // This is a one-line comment
    
  3. 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. (The // comments are simpler and easier to read.) However, it is strongly recommended to use HTML comments for hiding JavaScript code from old browsers.

JavaScripter.net. Copyright © 1999-2006, Alexei Kourbatov

The JavaScript FAQ
Prev Home Next


 
 
  Mirrored with kind permission of Alexei Kourbatov Design by Interspire