Merge pull request #2 from sagarjs/master

Added singular plural to differentiate between value and array of values
This commit is contained in:
Artem Zakharchenko 2019-11-26 19:17:28 +01:00 committed by GitHub
commit dbd554dd60
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'];
```