freeCodeCamp/guide/chinese/javascript/tutorials/comment-your-javascript-code/index.md

22 lines
547 B
Markdown
Raw Normal View History

---
title: Comment Your JavaScript Code
localeTitle: 评论您的JavaScript代码
---
评论是留给自己和其他人的好方法,后者需要弄清楚它的作用。其中的任何代码都将被忽略。
我们来看看用JavaScript编写注释的两种方法。
* 双斜杠注释将注释掉当前行的文本的其余部分:
`// This is a single line comment.`
* 斜杠 - 星 - 星 - 斜杠评论将注释掉`/*`和`*/`字符之间的所有内容:
```javascript
/*
This is
a multi-line comment
(comment block)
*/
```