Comments
Javascript comments (Javascript注释)
We usually use JavaScript comments for explaining JavaScript code and making it more readable. They also can be used to prevent execution during testing alternative code. (我们通常使用JavaScript注释来解释JavaScript代码,使其更具可读性。它们还可用于防止在测试替代代码期间执行。)
There are exists two types of comments: single line comments and multi-line comments. The example which you see here uses a single-line comment before each code line:
<!DOCTYPE HTML>
<html>
<body>
<p>Javascript comments: //</p>
<script>
// console.log('Welcome to w3cdoc!');
</script>
</body>
</html>
We use single line comments for writing small notes. You just need to add // before your code or text. Note that any kind of text between // and the end of the line will be ignored by JavaScript. (我们使用单行注释来写小笔记。您只需在代码或文本之前添加//。请注意,//和行尾之间的任何类型的文本都将被JavaScript忽略。)
As concerns multi-line comments, there are long segments of code that we used to disable. You need to add /* before your code and / after it. Start with / and end with /. Remember, that any text between / and / will be ignored by JavaScript. (关于多行注释,我们曾经禁用过长段代码。您需要在代码前添加/ ,并在代码后添加*/。以/开头,以/结尾。请记住,/和/之间的任何文本都将被JavaScript忽略。)
<!DOCTYPE HTML>
<html>
<body>
<p>Javascript comments: /* */</p>
<script>
/* console.log('Welcome to w3cdoc!');
alert("Welcome to w3cdoc"); */
</script>
</body>
</html>