27 lines
712 B
Markdown
27 lines
712 B
Markdown
---
|
||
title: Naming Convention for JavaScript
|
||
localeTitle: JavaScript的命名约定
|
||
---
|
||
在这里,您将了解广泛使用的不同代码案例。
|
||
|
||
## 骆驼香烟盒
|
||
|
||
在编程中,变量名称的camelCase格式如下所示:
|
||
```
|
||
var camelCase = "lower-case first word, capitalize each subsequent word";
|
||
```
|
||
|
||
## PascalCase
|
||
|
||
PascalCase(或CamelCase)是camelCase的变体。它与camelCase的不同之处在于大写每个单词, _包括_第一个单词:
|
||
```
|
||
var PascalCase = "upper-case every word";
|
||
```
|
||
|
||
## snake\_case
|
||
|
||
另一个名为snake\_case的流行案例以这种方式用下划线分隔每个单词:
|
||
```
|
||
var snake_case = "lower-case everything, but separate words with underscores";
|
||
|
||
``` |