| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 19db19b commit e6bed4e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,7 +104,7 @@ more on color support in terminal environments, read the tty | |||
| 104 | 104 | ||
| 105 | 105 | ## Legacy assertion mode | |
| 106 | 106 | ||
| 107 | - Legacy assertion mode uses the [Abstract Equality Comparison][] in: | ||
| 107 | + Legacy assertion mode uses the `==` operator in: | ||
| 108 | 108 | ||
| 109 | 109 | * [`assert.deepEqual()`][] | |
| 110 | 110 | * [`assert.equal()`][] | |
@@ -121,13 +121,11 @@ import assert from 'assert'; | |||
| 121 | 121 | const assert = require('assert'); | |
| 122 | 122 | ``` | |
| 123 | 123 | ||
| 124 | - Whenever possible, use the [strict assertion mode][] instead. Otherwise, the | ||
| 125 | - [Abstract Equality Comparison][] may cause surprising results. This is | ||
| 126 | - especially true for [`assert.deepEqual()`][], where the comparison rules are | ||
| 127 | - lax: | ||
| 124 | + Legacy assertion mode may have surprising results, especially when using | ||
| 125 | + [`assert.deepEqual()`][]: | ||
| 128 | 126 | ||
| 129 | 127 | ```cjs | |
| 130 | - // WARNING: This does not throw an AssertionError! | ||
| 128 | + // WARNING: This does not throw an AssertionError in legacy assertion mode! | ||
| 131 | 129 | assert.deepEqual(/a/gi, new Date()); | |
| 132 | 130 | ``` | |
| 133 | 131 | ||
@@ -473,7 +471,7 @@ changes: | |||
| 473 | 471 | Legacy. | |
| 474 | 472 | - version: v14.0.0 | |
| 475 | 473 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 476 | - description: NaN is now treated as being identical in case both sides are | ||
| 474 | + description: NaN is now treated as being identical if both sides are | ||
| 477 | 475 | NaN. | |
| 478 | 476 | - version: v12.0.0 | |
| 479 | 477 | pr-url: https://github.com/nodejs/node/pull/25008 | |
@@ -523,8 +521,8 @@ are also recursively evaluated by the following rules. | |||
| 523 | 521 | ||
| 524 | 522 | ### Comparison details | |
| 525 | 523 | ||
| 526 | - * Primitive values are compared with the [Abstract Equality Comparison][] | ||
| 527 | - ( `==` ) with the exception of `NaN`. It is treated as being identical in case | ||
| 524 | + * Primitive values are compared with the `==` operator, | ||
| 525 | + with the exception of `NaN`. It is treated as being identical in case | ||
| 528 | 526 | both sides are `NaN`. | |
| 529 | 527 | * [Type tags][Object.prototype.toString()] of objects should be the same. | |
| 530 | 528 | * Only [enumerable "own" properties][] are considered. | |
@@ -541,8 +539,7 @@ are also recursively evaluated by the following rules. | |||
| 541 | 539 | * [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values. | |
| 542 | 540 | ||
| 543 | 541 | The following example does not throw an [`AssertionError`][] because the | |
| 544 | - primitives are considered equal by the [Abstract Equality Comparison][] | ||
| 545 | - ( `==` ). | ||
| 542 | + primitives are compared using the `==` operator. | ||
| 546 | 543 | ||
| 547 | 544 | ```mjs | |
| 548 | 545 | import assert from 'assert'; | |
@@ -1142,7 +1139,7 @@ changes: | |||
| 1142 | 1139 | Legacy. | |
| 1143 | 1140 | - version: v14.0.0 | |
| 1144 | 1141 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 1145 | - description: NaN is now treated as being identical in case both sides are | ||
| 1142 | + description: NaN is now treated as being identical if both sides are | ||
| 1146 | 1143 | NaN. | |
| 1147 | 1144 | --> | |
| 1148 | 1145 | ||
@@ -1159,8 +1156,8 @@ An alias of [`assert.strictEqual()`][]. | |||
| 1159 | 1156 | > Stability: 3 - Legacy: Use [`assert.strictEqual()`][] instead. | |
| 1160 | 1157 | ||
| 1161 | 1158 | Tests shallow, coercive equality between the `actual` and `expected` parameters | |
| 1162 | - using the [Abstract Equality Comparison][] ( `==` ). `NaN` is special handled | ||
| 1163 | - and treated as being identical in case both sides are `NaN`. | ||
| 1159 | + using the `==` operator. `NaN` is specially handled | ||
| 1160 | + and treated as being identical if both sides are `NaN`. | ||
| 1164 | 1161 | ||
| 1165 | 1162 | ```mjs | |
| 1166 | 1163 | import assert from 'assert'; | |
@@ -1477,7 +1474,7 @@ changes: | |||
| 1477 | 1474 | Legacy. | |
| 1478 | 1475 | - version: v14.0.0 | |
| 1479 | 1476 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 1480 | - description: NaN is now treated as being identical in case both sides are | ||
| 1477 | + description: NaN is now treated as being identical if both sides are | ||
| 1481 | 1478 | NaN. | |
| 1482 | 1479 | - version: v9.0.0 | |
| 1483 | 1480 | pr-url: https://github.com/nodejs/node/pull/15001 | |
@@ -1661,7 +1658,7 @@ changes: | |||
| 1661 | 1658 | Legacy. | |
| 1662 | 1659 | - version: v14.0.0 | |
| 1663 | 1660 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 1664 | - description: NaN is now treated as being identical in case both sides are | ||
| 1661 | + description: NaN is now treated as being identical if both sides are | ||
| 1665 | 1662 | NaN. | |
| 1666 | 1663 | --> | |
| 1667 | 1664 | ||
@@ -1677,8 +1674,8 @@ An alias of [`assert.notStrictEqual()`][]. | |||
| 1677 | 1674 | ||
| 1678 | 1675 | > Stability: 3 - Legacy: Use [`assert.notStrictEqual()`][] instead. | |
| 1679 | 1676 | ||
| 1680 | - Tests shallow, coercive inequality with the [Abstract Equality Comparison][] | ||
| 1681 | - (`!=` ). `NaN` is special handled and treated as being identical in case both | ||
| 1677 | + Tests shallow, coercive inequality with the | ||
| 1678 | + `!=` operator. `NaN` is specially handled and treated as being identical if | ||
| 1682 | 1679 | sides are `NaN`. | |
| 1683 | 1680 | ||
| 1684 | 1681 | ```mjs | |
@@ -2438,7 +2435,6 @@ assert.throws(throwingFirst, /Second$/); | |||
| 2438 | 2435 | Due to the confusing error-prone notation, avoid a string as the second | |
| 2439 | 2436 | argument. | |
| 2440 | 2437 | ||
| 2441 | - [Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison | ||
| 2442 | 2438 | [Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript | |
| 2443 | 2439 | [Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring | |
| 2444 | 2440 | [SameValue Comparison]: https://tc39.github.io/ecma262/#sec-samevalue | |
@@ -2474,4 +2470,3 @@ argument. | |||
| 2474 | 2470 | [`tracker.verify()`]: #trackerverify | |
| 2475 | 2471 | [enumerable "own" properties]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties | |
| 2476 | 2472 | [prototype-spec]: https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots | |
| 2477 | - [strict assertion mode]: #strict-assertion-mode | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments