Skip to content

Commit 3c68fc4

Browse files
author
Jake Teton-Landis
committed
Reformat var change
1 parent b61d52c commit 3c68fc4

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

README.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -367,30 +367,28 @@
367367
```
368368
369369
- 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.
370373
371374
```javascript
372375
// bad
373376
var items = getItems(),
374377
goSportsTeam = true,
375378
dragonball = 'z';
376379

380+
// bad
381+
// (compare to above, and try to spot the mistake)
382+
var items = getItems(),
383+
goSportsTeam = true;
384+
dragonball = 'z';
385+
377386
// good
378387
var items = getItems();
379388
var goSportsTeam = true;
380389
var dragonball = 'z';
381390
```
382391
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-
394392
- 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.
395393
396394
```javascript

0 commit comments

Comments
 (0)