Added singular plural to differentiate between value and array of values

This commit is contained in:
sagarjs 2019-10-31 11:01:19 +05:30 committed by GitHub
parent c234734ab2
commit 7f0df7c9e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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'];
```