mirror of
https://github.com/kettanaito/naming-cheatsheet.git
synced 2025-08-09 06:45:00 +02:00
Update README.md
This commit is contained in:
committed by
GitHub
parent
d75d867ea5
commit
96b71a8c14
22
README.md
22
README.md
@ -110,14 +110,17 @@ link.addEventListener('click', handleLinkClick);
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Prefixes
|
## Prefixes
|
||||||
|
Prefixes enhance variables/methods, and serve as a quick indicators of additional meaning behind them.
|
||||||
|
|
||||||
#### `is`
|
#### `is`
|
||||||
Describes certain characteristic of the context.
|
Describes certain characteristic or state of the context.
|
||||||
```js
|
```js
|
||||||
const color = 'blue';
|
const color = 'blue';
|
||||||
const isBlue = (color === 'blue');
|
const isBlue = (color === 'blue'); // characteristic
|
||||||
|
const isRemoved = false; // state
|
||||||
|
|
||||||
if (isBlue) {
|
if (isBlue && !isRemoved) {
|
||||||
console.log('The color is blue!');
|
console.log('The color is blue and it is present!');
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -130,6 +133,17 @@ function PostsList() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### `has`
|
||||||
|
Describes whether current context possesses a certain value or state.
|
||||||
|
```js
|
||||||
|
/* Bad */
|
||||||
|
const isProductsExist = (productsCount > 0);
|
||||||
|
const areProductsPresent = (productsCount > 0);
|
||||||
|
|
||||||
|
/* Good */
|
||||||
|
const hasProducts = (productsCount > 0);
|
||||||
|
```
|
||||||
|
|
||||||
#### `should`
|
#### `should`
|
||||||
Reflects conditional statement (returns `Boolean` value).
|
Reflects conditional statement (returns `Boolean` value).
|
||||||
```js
|
```js
|
||||||
|
Reference in New Issue
Block a user