编程语言/命名:修订间差异
来自康健生活
< 编程语言
| 第15行: | 第15行: | ||
构造函数首字母应该{{underline|小|blue}}写<ref>Douglas Crockford. JavaScript: The Good Parts. O'Reily. 2008.</ref>。 | 构造函数首字母应该{{underline|小|blue}}写<ref>Douglas Crockford. JavaScript: The Good Parts. O'Reily. 2008.</ref>。 | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
var | var nowDateStrLength = dateStrLength(nowDate); // dateStrLength is a ordinary function.</syntaxhighlight> | ||
==== 构造函数命名 ==== | ==== 构造函数命名 ==== | ||
2020年6月12日 (五) 03:47的版本
引言
原则[1]:
- 选择专业的词汇
- 选择更具表现力的词汇
- 避免模糊的词汇
- 避免简洁的词汇
- 附带更多信息在词尾
- eq:
_ms毫秒、_secs、_mb、_kbps
- eq:
命名方法
匈牙利表示法
其他
函数命名
普通函数命名
构造函数首字母应该小写[2]。
var nowDateStrLength = dateStrLength(nowDate); // dateStrLength is a ordinary function.
构造函数命名
构造函数首字母应该大写。
var nowDate = new DateFormat(); // DateFormat is a constructor function.
实例
| of还是for | 示例 | 示例 |
| 示例 | 示例 | 示例 |
| 示例 | 示例 | 示例 |
No categories