* [17.1](https://github.com/yuche/javascript#17.1)?使用?`/** ... */`?作為多行注釋。包含描述、指定所有參數和返回值的類型和值。
~~~
// bad
// make() returns a new element
// based on the passed in tag name
//
// @param {String} tag
// @return {Element} element
function make(tag) {
// ...stuff...
return element;
}
// good
/**
* make() returns a new element
* based on the passed in tag name
*
* @param {String} tag
* @return {Element} element
*/
function make(tag) {
// ...stuff...
return element;
}
~~~
* [17.2](https://github.com/yuche/javascript#17.2)?使用?`//`?作為單行注釋。在評論對象上面另起一行使用單行注釋。在注釋前插入空行。
~~~
// bad
const active = true; // is current tab
// good
// is current tab
const active = true;
// bad
function getType() {
console.log('fetching type...');
// set the default type to 'no type'
const type = this._type || 'no type';
return type;
}
// good
function getType() {
console.log('fetching type...');
// set the default type to 'no type'
const type = this._type || 'no type';
return type;
}
~~~
* [17.3](https://github.com/yuche/javascript#17.3)?給注釋增加?`FIXME`?或?`TODO`?的前綴可以幫助其他開發者快速了解這是一個需要復查的問題,或是給需要實現的功能提供一個解決方式。這將有別于常見的注釋,因為它們是可操作的。使用`FIXME -- need to figure this out`?或者?`TODO -- need to implement`。
* [17.4](https://github.com/yuche/javascript#17.4)?使用?`// FIXME`: 標注問題。
~~~
class Calculator {
constructor() {
// FIXME: shouldn't use a global here
total = 0;
}
}
~~~
* [17.5](https://github.com/yuche/javascript#17.5)?使用?`// TODO`: 標注問題的解決方式。
~~~
class Calculator {
constructor() {
// TODO: total should be configurable by an options param
this.total = 0;
}
}
~~~
- 關于
- 1. 類型
- 2. 引用
- 3. 對象
- 4. 數組
- 5. 解構
- 6. 字符串
- 7. 函數
- 8. 箭頭函數
- 9. 構造函數
- 10. 模塊
- 11. Iterators & Generators
- 12. 屬性
- 13. 變量
- 14. 提升
- 15. 比較運算符 & 等號
- 16. 代碼塊
- 17. 注釋
- 18. 空白
- 19. 逗號
- 20. 分號
- 21. 類型轉換
- 22. 命名規則
- 23. 存取器
- 24. 事件
- 25. jQuery
- 26. ECMAScript 5 兼容性
- 27. ECMAScript 6 編碼規范
- 28. 測試
- 29. 性能
- 30. 資源
- 31. 使用人群
- 32. 翻譯
- 33. JavaScript 編碼規范說明
- 34. 一起來討論Javascript
- 35. Contributors
- 36. License