Skip to content

Commit cb83b55

Browse files
author
Peter Marton
committed
Avoid redundant variable names
1 parent aec9d0a commit cb83b55

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,23 @@ Heavily inspired by them as well:
374374
var i;
375375
```
376376
377+
- Avoid redundant variable names, use `Object`s instead.
378+
379+
```javascript
380+
381+
// bad
382+
var kaleidoscopeName = '..';
383+
var kaleidoscopeLens = [];
384+
var kaleidoscopeColors = [];
385+
386+
// good
387+
var kaleidoscope {
388+
name: '..',
389+
lens: [],
390+
colors: []
391+
};
392+
```
393+
377394
- Assign variables at the top of their scope. This helps avoid issues with variable declaration and assignment hoisting related issues.
378395
379396
```javascript
@@ -438,7 +455,7 @@ Heavily inspired by them as well:
438455
- core modules
439456
- npm modules
440457
- others
441-
458+
442459
```javascript
443460
// bad
444461
var Car = require('./models/Car');

0 commit comments

Comments
 (0)