Browse Source

feat: amazing reserved word/keywords

Add a rule: "Try to use reserved word/keywords as variable and function names"
pull/9/head
ForkΨKillet 5 years ago
committed by GitHub
parent
commit
eea4b2763e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      README.md

38
README.md

@ -239,6 +239,30 @@ function sum(a: number, b: number): ?number {
const guessWhat = sum([], {}); // -> undefined
```
### 💩 Try to use reserved word/keywords as variable and function names
That can make your code more "clear"!
_Good 👍🏻_
```javascript
function async()
{
var let = { await: "null", class: "undefined" };
for (let of in let) console.log(of + let[of]);
}
```
_Bad 👎🏻_
```javascript
function my_async()
{
var let_to_do = { if_await: "null", type: "undefined" };
for (let oF in let_to_do) console.log(oF + let_to_do[oF]);
}
```
### 💩 You need to have an unreachable piece of code
This is your "Plan B".
@ -259,6 +283,20 @@ function square(num) {
_Bad 👎🏻_
```javascript
function square(num) {
if (typeof num === 'undefined') {
return undefined;
}
else {
return num ** 2;
}
return null; // This is my "Plan B".
}
```
_Bad 👎🏻_
```javascript
function square(num) {
if (typeof num === 'undefined') {

Loading…
Cancel
Save