From 36638a93d824d1f5fdd553001961ccbf82614a6c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 5 Jan 2022 14:50:27 -0800 Subject: [PATCH 1/2] doc: add reference for == and != operators Refs: https://github.com/nodejs/node/pull/41375#issuecomment-1003763712 --- doc/api/assert.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index 1295f3b16082ba..2f5de95756e76b 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -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()`][] @@ -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. @@ -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'; @@ -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 @@ -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 sides are `NaN`. ```mjs import assert from 'assert'; @@ -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 From 3605c0d0557de7f60893bdfb3d173252f577e0b8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 5 Jan 2022 14:53:50 -0800 Subject: [PATCH 2/2] Update doc/api/assert.md --- doc/api/assert.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index 2f5de95756e76b..dc6d9d536db461 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -1685,7 +1685,7 @@ 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`. +specially handled and treated as being identical if both sides are `NaN`. ```mjs import assert from 'assert';