Skip to content

Commit 2fb5e1d

Browse files
committed
Back to top links
1 parent 5bf7a2a commit 2fb5e1d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

README.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var yyyymmdstr = moment().format('YYYY/MM/DD');
2222
```javascript
2323
var yearMonthDay = moment().format('YYYY/MM/DD');
2424
```
25+
**[⬆ back to top](#table-of-contents)**
2526

2627
### Use the same vocabulary for the same type of variable
2728

@@ -36,7 +37,6 @@ getCustomerRecord();
3637
```javascript
3738
getUser();
3839
```
39-
4040
**[⬆ back to top](#table-of-contents)**
4141

4242
### Use searchable names
@@ -58,6 +58,7 @@ for (var i = 0; i < MINUTES_IN_A_YEAR; i++) {
5858
runCronJob();
5959
}
6060
```
61+
**[⬆ back to top](#table-of-contents)**
6162

6263
### Avoid Mental Mapping
6364
Explicit is better than implicit.
@@ -88,6 +89,7 @@ locations.forEach((location) => {
8889
dispatch(location);
8990
});
9091
```
92+
**[⬆ back to top](#table-of-contents)**
9193

9294
### Use consistent capitalization
9395
JavaScript is untyped, so capitalization tells you a lot about your variables,
@@ -123,6 +125,7 @@ function restoreDatabase() {}
123125
class Animal {}
124126
class Alpaca {}
125127
```
128+
**[⬆ back to top](#table-of-contents)**
126129

127130
### Don't add unneeded context
128131
If your class/object name tells you something, don't repeat that in your
@@ -153,6 +156,7 @@ function paintCar(car) {
153156
car.color = 'Red';
154157
}
155158
```
159+
**[⬆ back to top](#table-of-contents)**
156160

157161
## **Functions**
158162
### Limit the amount of function parameters (2 or less)
@@ -179,6 +183,7 @@ function createMenu(config) {
179183
}
180184

181185
```
186+
**[⬆ back to top](#table-of-contents)**
182187

183188
### Use default arguments instead of short circuiting
184189
**Bad:**
@@ -187,6 +192,7 @@ function writeForumComment(subject, body) {
187192
subject = subject || 'No Subject';
188193
body = body || 'No text';
189194
}
195+
190196
```
191197

192198
**Good**:
@@ -196,6 +202,7 @@ function writeForumComment(subject='No subject', body='No text') {
196202
}
197203

198204
```
205+
**[⬆ back to top](#table-of-contents)**
199206

200207
### Don't use flags as function parameters
201208
Flags tell your user that this function does more than one thing. Functions should do one thing. Split out your functions if they are following different code paths based on a boolean.
@@ -209,7 +216,6 @@ function createFile(name, temp) {
209216
fs.create(name);
210217
}
211218
}
212-
213219
```
214220

215221
**Good**:
@@ -222,6 +228,7 @@ function createFile(name) {
222228
fs.create(name);
223229
}
224230
```
231+
**[⬆ back to top](#table-of-contents)**
225232

226233
### Avoid Side Effects
227234
A function produces a side effect if it does anything other than take a value in
@@ -255,6 +262,7 @@ var newName = splitIntoFirstAndLastName(name);
255262
console.log(name); // 'Ryan McDermott';
256263
console.log(newName); // ['Ryan', 'McDermott'];
257264
```
265+
**[⬆ back to top](#table-of-contents)**
258266

259267
### Don't write to global functions
260268
Polluting globals is a bad practice in JavaScript because you could clash with another
@@ -312,6 +320,7 @@ class SuperArray extends Array {
312320
}
313321
}
314322
```
323+
**[⬆ back to top](#table-of-contents)**
315324

316325
## **Classes**
317326
### Prefer ES6 classes over ES5 plain functions
@@ -387,6 +396,7 @@ class Human extends Mammal {
387396
speak() {}
388397
}
389398
```
399+
**[⬆ back to top](#table-of-contents)**
390400

391401
## **Comments**
392402
### Only comment things that have business logic complexity.
@@ -430,6 +440,7 @@ function hashIt(data) {
430440
}
431441

432442
```
443+
**[⬆ back to top](#table-of-contents)**
433444

434445
### Don't leave commented code in your codebase
435446
Version control exists for a reason. Leave old code in your history.
@@ -446,3 +457,4 @@ doStuff();
446457
```javascript
447458
doStuff();
448459
```
460+
**[⬆ back to top](#table-of-contents)**

0 commit comments

Comments
 (0)