| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c951512 commit 14068f8
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 | ||
@@ -471,7 +469,7 @@ changes: | |||
| 471 | 469 | Legacy. | |
| 472 | 470 | - version: v14.0.0 | |
| 473 | 471 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 474 | - description: NaN is now treated as being identical in case both sides are | ||
| 472 | + description: NaN is now treated as being identical if both sides are | ||
| 475 | 473 | NaN. | |
| 476 | 474 | - version: v12.0.0 | |
| 477 | 475 | pr-url: https://github.com/nodejs/node/pull/25008 | |
@@ -521,8 +519,8 @@ are also recursively evaluated by the following rules. | |||
| 521 | 519 | ||
| 522 | 520 | ### Comparison details | |
| 523 | 521 | ||
| 524 | - * Primitive values are compared with the [Abstract Equality Comparison][] | ||
| 525 | - ( `==` ) with the exception of `NaN`. It is treated as being identical in case | ||
| 522 | + * Primitive values are compared with the `==` operator, | ||
| 523 | + with the exception of `NaN`. It is treated as being identical in case | ||
| 526 | 524 | both sides are `NaN`. | |
| 527 | 525 | * [Type tags][Object.prototype.toString()] of objects should be the same. | |
| 528 | 526 | * Only [enumerable "own" properties][] are considered. | |
@@ -539,8 +537,7 @@ are also recursively evaluated by the following rules. | |||
| 539 | 537 | * [`WeakMap`][] and [`WeakSet`][] comparison does not rely on their values. | |
| 540 | 538 | ||
| 541 | 539 | The following example does not throw an [`AssertionError`][] because the | |
| 542 | - primitives are considered equal by the [Abstract Equality Comparison][] | ||
| 543 | - ( `==` ). | ||
| 540 | + primitives are compared using the `==` operator. | ||
| 544 | 541 | ||
| 545 | 542 | ```mjs | |
| 546 | 543 | import assert from 'assert'; | |
@@ -1138,7 +1135,7 @@ changes: | |||
| 1138 | 1135 | Legacy. | |
| 1139 | 1136 | - version: v14.0.0 | |
| 1140 | 1137 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 1141 | - description: NaN is now treated as being identical in case both sides are | ||
| 1138 | + description: NaN is now treated as being identical if both sides are | ||
| 1142 | 1139 | NaN. | |
| 1143 | 1140 | --> | |
| 1144 | 1141 | ||
@@ -1155,8 +1152,8 @@ An alias of [`assert.strictEqual()`][]. | |||
| 1155 | 1152 | > Stability: 3 - Legacy: Use [`assert.strictEqual()`][] instead. | |
| 1156 | 1153 | ||
| 1157 | 1154 | Tests shallow, coercive equality between the `actual` and `expected` parameters | |
| 1158 | - using the [Abstract Equality Comparison][] ( `==` ). `NaN` is special handled | ||
| 1159 | - and treated as being identical in case both sides are `NaN`. | ||
| 1155 | + using the `==` operator. `NaN` is specially handled | ||
| 1156 | + and treated as being identical if both sides are `NaN`. | ||
| 1160 | 1157 | ||
| 1161 | 1158 | ```mjs | |
| 1162 | 1159 | import assert from 'assert'; | |
@@ -1471,7 +1468,7 @@ changes: | |||
| 1471 | 1468 | Legacy. | |
| 1472 | 1469 | - version: v14.0.0 | |
| 1473 | 1470 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 1474 | - description: NaN is now treated as being identical in case both sides are | ||
| 1471 | + description: NaN is now treated as being identical if both sides are | ||
| 1475 | 1472 | NaN. | |
| 1476 | 1473 | - version: v9.0.0 | |
| 1477 | 1474 | pr-url: https://github.com/nodejs/node/pull/15001 | |
@@ -1653,7 +1650,7 @@ changes: | |||
| 1653 | 1650 | Legacy. | |
| 1654 | 1651 | - version: v14.0.0 | |
| 1655 | 1652 | pr-url: https://github.com/nodejs/node/pull/30766 | |
| 1656 | - description: NaN is now treated as being identical in case both sides are | ||
| 1653 | + description: NaN is now treated as being identical if both sides are | ||
| 1657 | 1654 | NaN. | |
| 1658 | 1655 | --> | |
| 1659 | 1656 | ||
@@ -1669,8 +1666,8 @@ An alias of [`assert.notStrictEqual()`][]. | |||
| 1669 | 1666 | ||
| 1670 | 1667 | > Stability: 3 - Legacy: Use [`assert.notStrictEqual()`][] instead. | |
| 1671 | 1668 | ||
| 1672 | - Tests shallow, coercive inequality with the [Abstract Equality Comparison][] | ||
| 1673 | - (`!=` ). `NaN` is special handled and treated as being identical in case both | ||
| 1669 | + Tests shallow, coercive inequality with the | ||
| 1670 | + `!=` operator. `NaN` is specially handled and treated as being identical if | ||
| 1674 | 1671 | sides are `NaN`. | |
| 1675 | 1672 | ||
| 1676 | 1673 | ```mjs | |
@@ -2430,7 +2427,6 @@ assert.throws(throwingFirst, /Second$/); | |||
| 2430 | 2427 | Due to the confusing error-prone notation, avoid a string as the second | |
| 2431 | 2428 | argument. | |
| 2432 | 2429 | ||
| 2433 | - [Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison | ||
| 2434 | 2430 | [Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript | |
| 2435 | 2431 | [Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring | |
| 2436 | 2432 | [SameValue Comparison]: https://tc39.github.io/ecma262/#sec-samevalue | |
@@ -2466,4 +2462,3 @@ argument. | |||
| 2466 | 2462 | [`tracker.verify()`]: #trackerverify | |
| 2467 | 2463 | [enumerable "own" properties]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties | |
| 2468 | 2464 | [prototype-spec]: https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots | |
| 2469 | - [strict assertion mode]: #strict-assertion-mode | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments