Home > Web Front-end > Front-end Q&A > Can Javascript be commented with double slashes?

Can Javascript be commented with double slashes?

WBOY
Release: 2022-03-03 10:54:49
Original
2423 people have browsed it

In JavaScript, you can use double slashes to comment; use "//" to make single-line comments on JavaScript code, the syntax is "//single-line comment content", use "/*" and "*/ "You can make multi-line comments on JavaScript code, and the syntax is "/*Multi-line comment content*/".

Can Javascript be commented with double slashes?

The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.

Can JavaScript be commented with double slashes?

We can add comments to explain JavaScript or improve the readability of the code.

Single-line comments begin with // .

This example uses a single-line comment to explain the code:

Example

// 输出标题:
document.getElementById("myH1").innerHTML="欢迎来到我的主页";
// 输出段落:
document.getElementById("myP").innerHTML="这是我的第一个段落。";
Copy after login

Multi-line comments start with /* and end with */.

The following example uses multi-line comments to explain the code:

Example

/*
下面的这些代码会输出
一个标题和一个段落
并将代表主页的开始
*/
document.getElementById("myH1").innerHTML="欢迎来到我的主页";
document.getElementById("myP").innerHTML="这是我的第一个段落。";
Copy after login

Related recommendations: javascript learning tutorial

The above is the detailed content of Can Javascript be commented with double slashes?. 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