Home > Web Front-end > JS Tutorial > body text

What are the three ways to write comments in JavaScript?

醉折花枝作酒筹
Release: 2023-01-04 09:35:07
Original
8719 people have browsed it

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红海 */ 这里的内容就不会被显示
Copy after login

2、/ /Single line comment

// 不断学习
Copy after login

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 编程艺术
Copy after login

[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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template