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*/".
The operating environment of this tutorial: Windows 10 system, JavaScript version 1.8.5, Dell G3 computer.
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="这是我的第一个段落。";
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="这是我的第一个段落。";
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!