Home > Web Front-end > Front-end Q&A > Why are there three ways to write comments in JavaScript?

Why are there three ways to write comments in JavaScript?

青灯夜游
Release: 2021-06-30 18:38:07
Original
1550 people have browsed it

Three ways to write comments in JavaScript: 1. Multi-line comments, the syntax "/* Content to be commented */"; 2. Single-line comments, the syntax "// Content to be commented"; 3. "< ;!-- Content to comment".

Why are there three ways to write comments in JavaScript?

The operating environment of this tutorial: windows7 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. Three basic ways

1. Multi-line comments

Syntax:

/* 这里写上要注释的东西*/
Copy after login

2. Single-line comments

Grammar:

// 要注释的内容
Copy after login

3, <!--

## Grammar:

<!-- 要注释的内容
Copy after login
Although in strict mode No error is reported, but this method is not recommended because it is easily confused with the HTML comment method.

[Related recommendations:

javascript learning tutorial]

The above is the detailed content of Why are there 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