freeCodeCamp/guide/chinese/javascript/naming-convention-for-javas.../index.md

27 lines
712 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
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";
```