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
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -367,30 +367,28 @@
367
367
```
368
368
369
369
- Use one `var` declaration per variable.
370
+
It's easier to add new variable declarations this way, and you never have
371
+
to worry about swapping out a `;` for a `,` or introducing punctuation-only
372
+
diffs.
370
373
371
374
```javascript
372
375
// bad
373
376
var items =getItems(),
374
377
goSportsTeam =true,
375
378
dragonball ='z';
376
379
380
+
// bad
381
+
// (compare to above, and try to spot the mistake)
382
+
var items =getItems(),
383
+
goSportsTeam =true;
384
+
dragonball ='z';
385
+
377
386
// good
378
387
var items =getItems();
379
388
var goSportsTeam =true;
380
389
var dragonball ='z';
381
390
```
382
391
383
-
It's easier to add new variable declarations this way, and you never have
384
-
to worry about swapping out a `;` for a `,` or introducing punctuation-only
385
-
diffs. Also, you can't make the following mistake:
386
-
387
-
```javascript
388
-
// can you catch the error?
389
-
var items =getItems(),
390
-
goSportsTeam =true;
391
-
dragonball ='z';
392
-
```
393
-
394
392
- Declare unassigned variables last. This is helpful when later on you might need to assign a variable depending on one of the previous assigned variables.
0 commit comments