forked from extern/naming-cheatsheet
Merge pull request #2 from sagarjs/master
Added singular plural to differentiate between value and array of values
This commit is contained in:
commit
dbd554dd60
16
README.md
16
README.md
@ -315,3 +315,19 @@ function fetchPosts() {
|
||||
this.setState({ posts: nextPosts })
|
||||
}
|
||||
```
|
||||
|
||||
## Singular/Plurals
|
||||
|
||||
Like a prefix, variable names can be made singular or plural depending on whether they hold a single value or multiple values.
|
||||
|
||||
|
||||
```js
|
||||
/* Bad */
|
||||
const friends = 'Bob';
|
||||
const friend = ['Bob', 'Tony', 'Tanya'];
|
||||
|
||||
/* Good */
|
||||
const friend = 'Bob';
|
||||
const friends = ['Bob', 'Tony', 'Tanya'];
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user