forked from extern/naming-cheatsheet
Added singular plural to differentiate between value and array of values
This commit is contained in:
parent
c234734ab2
commit
7f0df7c9e6
16
README.md
16
README.md
@ -315,3 +315,19 @@ function fetchPosts() {
|
|||||||
this.setState({ posts: nextPosts })
|
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