You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-3Lines changed: 35 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -995,7 +995,7 @@
995
995
996
996
## Naming Conventions
997
997
998
-
- Avoid single letter names. Be descriptive with your naming.
998
+
- Avoid single letter names. Be descriptive with your naming.Names representing types should be nouns. Names representing methods should be verbs or verb phrases.
999
999
1000
1000
```javascript
1001
1001
// bad
@@ -1009,7 +1009,7 @@
1009
1009
}
1010
1010
```
1011
1011
1012
-
- Use camelCase when naming objects, functions, and instances
1012
+
- Use camelCase when naming objects, functions, and instances. Abbreviations and acronyms should also use camel case when used as a name.
1013
1013
1014
1014
```javascript
1015
1015
// bad
@@ -1020,12 +1020,20 @@
1020
1020
name: 'Bob Parr'
1021
1021
});
1022
1022
1023
+
// bad
1024
+
function parseJSON() {};
1025
+
var XMLDocument;
1026
+
1023
1027
// good
1024
1028
var thisIsMyObject = {};
1025
1029
function thisIsMyFunction() {};
1026
1030
var user = new User({
1027
1031
name: 'Bob Parr'
1028
1032
});
1033
+
1034
+
// good
1035
+
function parseJson() {};
1036
+
var xmlDocument;
1029
1037
```
1030
1038
1031
1039
- Use PascalCase when naming constructors or classes
@@ -1050,6 +1058,16 @@
1050
1058
});
1051
1059
```
1052
1060
1061
+
- Use Screaming Snake Case for constants
1062
+
1063
+
```javascript
1064
+
// bad
1065
+
var some_constant = 5;
1066
+
1067
+
// good
1068
+
var SOME_CONSTANT = 5;
1069
+
```
1070
+
1053
1071
- Use a leading underscore `_` when naming private properties
1054
1072
1055
1073
```javascript
@@ -1089,7 +1107,7 @@
1089
1107
}
1090
1108
```
1091
1109
1092
-
- Name your functions. This is helpful for stack traces.
1110
+
- Name your functions. This is helpful for stack traces.Notethis is not necessary forclassmethods.
0 commit comments