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

doc: add reference for == and != operators #41413

Merged
merged 2 commits into from
Jan 8, 2022
Merged
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
15 changes: 8 additions & 7 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ more on color support in terminal environments, read the tty

## Legacy assertion mode

Legacy assertion mode uses the `==` operator in:
Legacy assertion mode uses the [`==` operator][] in:

* [`assert.deepEqual()`][]
* [`assert.equal()`][]
Expand Down Expand Up @@ -524,7 +524,7 @@ are also recursively evaluated by the following rules.

### Comparison details

* Primitive values are compared with the `==` operator,
* Primitive values are compared with the [`==` operator][],
with the exception of `NaN`. It is treated as being identical in case
both sides are `NaN`.
* [Type tags][Object.prototype.toString()] of objects should be the same.
Expand All @@ -544,7 +544,7 @@ are also recursively evaluated by the following rules.
are not enumerable properties.

The following example does not throw an [`AssertionError`][] because the
primitives are compared using the `==` operator.
primitives are compared using the [`==` operator][].

```mjs
import assert from 'assert';
Expand Down Expand Up @@ -1166,7 +1166,7 @@ An alias of [`assert.strictEqual()`][].
> Stability: 3 - Legacy: Use [`assert.strictEqual()`][] instead.

Tests shallow, coercive equality between the `actual` and `expected` parameters
using the `==` operator. `NaN` is specially handled
using the [`==` operator][]. `NaN` is specially handled
and treated as being identical if both sides are `NaN`.

```mjs
Expand Down Expand Up @@ -1684,9 +1684,8 @@ An alias of [`assert.notStrictEqual()`][].

> Stability: 3 - Legacy: Use [`assert.notStrictEqual()`][] instead.

Tests shallow, coercive inequality with the
`!=` operator. `NaN` is specially handled and treated as being identical if
sides are `NaN`.
Tests shallow, coercive inequality with the [`!=` operator][]. `NaN` is
specially handled and treated as being identical if both sides are `NaN`.

```mjs
import assert from 'assert';
Expand Down Expand Up @@ -2449,6 +2448,8 @@ argument.
[Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring
[SameValue Comparison]: https://tc39.github.io/ecma262/#sec-samevalue
[Strict Equality Comparison]: https://tc39.github.io/ecma262/#sec-strict-equality-comparison
[`!=` operator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Inequality
[`==` operator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
[`AssertionError`]: #class-assertassertionerror
[`CallTracker`]: #class-assertcalltracker
[`Class`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
Expand Down