Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: amazing reserved word/keywords #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 40 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,35 @@ 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".

_Good 👍🏻_
_Good 👍🏻_

```javascript
function square(num) {
Expand All @@ -255,7 +279,21 @@ function square(num) {
}
return null; // This is my "Plan B".
}
```
```

_Bad 👎🏻_

```javascript
function square(num) {
if (typeof num === 'undefined') {
return undefined;
}
else {
return num ** 2;
}
return null; // This is my "Plan B".
}
```

_Bad 👎🏻_

Expand Down