Skip to content

Commit

Permalink
Update 8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
loveyunk committed Dec 12, 2019
1 parent 1478555 commit 77e078c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1115,18 +1115,18 @@ Other Style Guides

```js
// 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;
};
```

Expand Down Expand Up @@ -2815,21 +2815,21 @@ Other Style Guides
// ..
}
}

// good
class Person {
constructor(fullName, email, birthday) {
this.fullName = fullName;
this.email = email;
this.setAge(birthday);
}

setAge(birthday) {
const today = new Date();
const age = getAge(today, birthday);
this.age = age;
}

getAge(today, birthday) {
// ..
}
Expand Down

0 comments on commit 77e078c

Please sign in to comment.