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

Comparing undefined to undefined #319

Open
wants to merge 2 commits 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,23 @@ true;
- [**7.2.15** Abstract Equality Comparison](https://262.ecma-international.org/11.0/index.html#sec-abstract-equality-comparison)
- [An in-depth explanation](https://blog.campvanilla.com/javascript-the-curious-case-of-null-0-7b131644e274)

## Comparing `undefined` to `undefined`

`undefined` is equal to `undefined` but is not greater than or equal to `undefined`:

```js
null == null; // true
null >= null; // true
undefined == undefined; // true
undefined >= undefined; // false
```

### 💡 Explanation:

- If at least one of the two values is not a string, JavaScript attempts to convert the non-numeric types into numeric values.
- [`Number(undefined)` returns `NaN`](#undefined-and-number).
- [`NaN` is not a `NaN`](#nan-is-not-a-nan).

## Same variable redeclaration

JS allows to redeclare variables:
Expand Down