@@ -10,7 +10,8 @@ readable, reusable, and refactorable software in JavaScript. Enjoy!
10
10
3 . [ Objects and Data Structures] ( #objects-and-data-structures )
11
11
4 . [ Classes] ( #classes )
12
12
5 . [ Concurrency] ( #concurrency )
13
- 6 . [ Comments] ( #comments )
13
+ 6 . [ Formatting] ( #formatting )
14
+ 7 . [ Comments] ( #comments )
14
15
15
16
## ** Variables**
16
17
### Use meaningful and pronounceable variable names
@@ -93,41 +94,6 @@ locations.forEach((location) => {
93
94
```
94
95
** [ ⬆ back to top] ( #table-of-contents ) **
95
96
96
- ### Use consistent capitalization
97
- JavaScript is untyped, so capitalization tells you a lot about your variables,
98
- functions, etc. These rules are subjective, so your team can choose whatever
99
- they want. The point is, no matter what you all choose, just be consistent.
100
-
101
- ** Bad:**
102
- ``` javascript
103
- var DAYS_IN_WEEK = 7 ;
104
- var daysInMonth = 30 ;
105
-
106
- var songs = [' Back In Black' , ' Stairway to Heaven' , ' Hey Jude' ];
107
- var Artists = [' ACDC' , ' Led Zeppelin' , ' The Beatles' ];
108
-
109
- function eraseDatabase () {}
110
- function restore_database () {}
111
-
112
- class animal {}
113
- class Alpaca {}
114
- ```
115
-
116
- ** Good** :
117
- ``` javascript
118
- var DAYS_IN_WEEK = 7 ;
119
- var DAYS_IN_MONTH = 30 ;
120
-
121
- var songs = [' Back In Black' , ' Stairway to Heaven' , ' Hey Jude' ];
122
- var artists = [' ACDC' , ' Led Zeppelin' , ' The Beatles' ];
123
-
124
- function eraseDatabase () {}
125
- function restoreDatabase () {}
126
-
127
- class Animal {}
128
- class Alpaca {}
129
- ```
130
- ** [ ⬆ back to top] ( #table-of-contents ) **
131
97
132
98
### Don't add unneeded context
133
99
If your class/object name tells you something, don't repeat that in your
@@ -1005,6 +971,44 @@ async function getCleanCodeArticle() {
1005
971
** [ ⬆ back to top] ( #table-of-contents ) **
1006
972
1007
973
974
+ ## ** Formatting**
975
+ ### Use consistent capitalization
976
+ JavaScript is untyped, so capitalization tells you a lot about your variables,
977
+ functions, etc. These rules are subjective, so your team can choose whatever
978
+ they want. The point is, no matter what you all choose, just be consistent.
979
+
980
+ ** Bad:**
981
+ ``` javascript
982
+ var DAYS_IN_WEEK = 7 ;
983
+ var daysInMonth = 30 ;
984
+
985
+ var songs = [' Back In Black' , ' Stairway to Heaven' , ' Hey Jude' ];
986
+ var Artists = [' ACDC' , ' Led Zeppelin' , ' The Beatles' ];
987
+
988
+ function eraseDatabase () {}
989
+ function restore_database () {}
990
+
991
+ class animal {}
992
+ class Alpaca {}
993
+ ```
994
+
995
+ ** Good** :
996
+ ``` javascript
997
+ var DAYS_IN_WEEK = 7 ;
998
+ var DAYS_IN_MONTH = 30 ;
999
+
1000
+ var songs = [' Back In Black' , ' Stairway to Heaven' , ' Hey Jude' ];
1001
+ var artists = [' ACDC' , ' Led Zeppelin' , ' The Beatles' ];
1002
+
1003
+ function eraseDatabase () {}
1004
+ function restoreDatabase () {}
1005
+
1006
+ class Animal {}
1007
+ class Alpaca {}
1008
+ ```
1009
+ ** [ ⬆ back to top] ( #table-of-contents ) **
1010
+
1011
+
1008
1012
## ** Comments**
1009
1013
### Only comment things that have business logic complexity.
1010
1014
Comments are an apology, not a requirement. Good code * mostly* documents itself.
0 commit comments