Skip to content

Commit

Permalink
no-typeof-undefined: Add historical note to docs (#1992)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Dec 3, 2022
1 parent 8dff476 commit 84a5816
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/rules/no-typeof-undefined.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

Checking if a value is `undefined` by using `typeof value === 'undefined'` is needlessly verbose. It's generally better to compare against `undefined` directly. The only time `typeof` is needed is when a global variable potentially does not exists, in which case, using `globalThis.value === undefined` may be better.

Historical note: Comparing against `undefined` without `typeof` was frowned upon until ES5. This is no longer a problem since all engines currently in use no longer allow reassigning the `undefined` global.

## Fail

```js
Expand Down

0 comments on commit 84a5816

Please sign in to comment.