Skip to content

Commit 5c225d5

Browse files
committed
Merge branch 'undefined'
2 parents baaafc2 + f3f953b commit 5c225d5

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/_sidebar.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@
4242
* [Scope](workflow/scope.md)
4343
* [Variable access](workflow/variable-access.md)
4444
* [How to clone](workflow/how-to-clone.md)
45+
* [null and undefined](workflow/null-and-undefined.md)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# null and undefined
2+
3+
While `null` means "no object", `undefined` is "no value".
4+
5+
The simple way for typecheck both value is using weak equal:
6+
7+
```js
8+
const isNil = value => value == null
9+
```
10+
11+
Although the problem is still there: everyone uses `null` and `undefined` inconsistently and interchangeably, not being clear when to use which.
12+
13+
We cannot remove `null` from JavaScript (e.g., JSON doesn't support `undefined`) but we can mitigate the impact.
14+
15+
In order to apply a simple rule there, just [use `undefined` over `null`](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#null-and-undefined).

0 commit comments

Comments
 (0)