JavaScript supports both C-style and C++-style comments. Any text between a // and the end of a line is treated as a comment and is ignored by JavaScript. Also, any text (which may cover multiple lines) between the characters /* and */ is treated as a comment.
In addition, JavaScript recognizes the HTML comment opening sequence <!--. JavaScript treats this as a single-line comment, just as it does the // comment, and does not recognize the HTML comment closing sequence -->. There is a special purpose for recognizing the HTML comment but treating it differently from HTML. In a JavaScript program, if the first line begins <!--, and the last line ends //-->, then the entire program is contained within an HTML comment and will be ignored (instead of formatted and displayed) by browsers that do not support JavaScript. Since the first line begins with <!-- and the last line begins with //, JavaScript ignores both, but does not ignore the lines in between. In this way, it is possible to hide code from web browsers that can't understand it, without hiding it from those that can. Because of the special purpose of the <!-- comment, you should use it only in the first line of your scripts; other uses would be confusing.
file: /Techref/language/JAVA/SCRIPT/definitive/ch02_04.htm, 4KB, , updated: 2019/10/14 15:00, local time: 2024/12/23 17:51,
3.140.195.8:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.ecomorder.com/Techref/language/JAVA/SCRIPT/definitive/ch02_04.htm"> [Chapter 2] 2.4 Comments</A> |
Did you find what you needed? |
Welcome to ecomorder.com! |
Welcome to massmind.ecomorder.com! |
.