Three ways to write comments in JavaScript: 1. Use "/*comment code*/" to make multi-line comments; 2. Use "//comment code" to make single-line comments; 3. Use "< ;!-- Content to be commented", single line comments can be made.
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, Dell G3 computer.
JavaSciprt comments will not be read by the browser and will be automatically skipped. Writing comments is important for you to go back and check quickly later. When writing comments, try to be concise and detailed. Let’s talk about the comments. The three basic methods
This is what I read in the book (mainly I have never seen the third method. In fact, the third method is easily confused with HTML, so there is no need).
1、/* Write what you want to comment here*/
Multi-line comments
如:/* IT红海 */ 这里的内容就不会被显示
2、/ /
Single line comment
// 不断学习
3, <!-- Content to be commented
Although no error is reported in strict mode, this method is not recommended. , because this method is easily confused with the HTML comment method and can only comment a single line. Do not add --> after this method. This is different from html comments.
<!-- JS DOM 编程艺术
[Recommended learning: javascript video tutorial]
The above is the detailed content of What are the three ways to write comments in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!