mirror of
https://github.com/airbnb/javascript.git
synced 2026-04-25 03:00:19 -04:00
Examples more consistent with the guidline
comparison operator <= shows better the confusion when using arrow function, than just operator <
This commit is contained in:
committed by
Jordan Harband
parent
6ece1f58e9
commit
69e34378c6
@@ -1052,18 +1052,18 @@ Other Style Guides
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
const itemHeight = item => item.height > 256 ? item.largeSize : item.smallSize;
|
||||
const itemHeight = item => item.height <= 256 ? item.largeSize : item.smallSize;
|
||||
|
||||
// bad
|
||||
const itemHeight = (item) => item.height > 256 ? item.largeSize : item.smallSize;
|
||||
const itemHeight = (item) => item.height >= 256 ? item.largeSize : item.smallSize;
|
||||
|
||||
// good
|
||||
const itemHeight = item => (item.height > 256 ? item.largeSize : item.smallSize);
|
||||
const itemHeight = item => (item.height <= 256 ? item.largeSize : item.smallSize);
|
||||
|
||||
// good
|
||||
const itemHeight = (item) => {
|
||||
const { height, largeSize, smallSize } = item;
|
||||
return height > 256 ? largeSize : smallSize;
|
||||
return height <= 256 ? largeSize : smallSize;
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user