mirror of https://github.com/nodejs/node.git
doc: remove SameValue comparison reference
Referring to `Object.is()` will be more clear and direct. The `Object.is()` reference in turn refers to `SameValue` so people can dig deeper there if they want or need to. PR-URL: https://github.com/nodejs/node/pull/41460 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Harshitha K P <harshitha014@gmail.com>
This commit is contained in:
parent
500241d50d
commit
25d0fbf12e
|
@ -686,8 +686,7 @@ are recursively evaluated also by the following rules.
|
||||||
|
|
||||||
### Comparison details
|
### Comparison details
|
||||||
|
|
||||||
* Primitive values are compared using the [SameValue Comparison][], used by
|
* Primitive values are compared using [`Object.is()`][].
|
||||||
[`Object.is()`][].
|
|
||||||
* [Type tags][Object.prototype.toString()] of objects should be the same.
|
* [Type tags][Object.prototype.toString()] of objects should be the same.
|
||||||
* [`[[Prototype]]`][prototype-spec] of objects are compared using
|
* [`[[Prototype]]`][prototype-spec] of objects are compared using
|
||||||
the [`===` operator][].
|
the [`===` operator][].
|
||||||
|
@ -741,7 +740,7 @@ assert.deepStrictEqual(date, fakeDate);
|
||||||
// - Date {}
|
// - Date {}
|
||||||
|
|
||||||
assert.deepStrictEqual(NaN, NaN);
|
assert.deepStrictEqual(NaN, NaN);
|
||||||
// OK, because of the SameValue comparison
|
// OK because Object.is(NaN, NaN) is true.
|
||||||
|
|
||||||
// Different unwrapped numbers:
|
// Different unwrapped numbers:
|
||||||
assert.deepStrictEqual(new Number(1), new Number(2));
|
assert.deepStrictEqual(new Number(1), new Number(2));
|
||||||
|
@ -757,7 +756,7 @@ assert.deepStrictEqual(new String('foo'), Object('foo'));
|
||||||
assert.deepStrictEqual(-0, -0);
|
assert.deepStrictEqual(-0, -0);
|
||||||
// OK
|
// OK
|
||||||
|
|
||||||
// Different zeros using the SameValue Comparison:
|
// Different zeros:
|
||||||
assert.deepStrictEqual(0, -0);
|
assert.deepStrictEqual(0, -0);
|
||||||
// AssertionError: Expected inputs to be strictly deep-equal:
|
// AssertionError: Expected inputs to be strictly deep-equal:
|
||||||
// + actual - expected
|
// + actual - expected
|
||||||
|
@ -833,7 +832,7 @@ assert.deepStrictEqual(date, fakeDate);
|
||||||
// - Date {}
|
// - Date {}
|
||||||
|
|
||||||
assert.deepStrictEqual(NaN, NaN);
|
assert.deepStrictEqual(NaN, NaN);
|
||||||
// OK, because of the SameValue comparison
|
// OK because Object.is(NaN, NaN) is true.
|
||||||
|
|
||||||
// Different unwrapped numbers:
|
// Different unwrapped numbers:
|
||||||
assert.deepStrictEqual(new Number(1), new Number(2));
|
assert.deepStrictEqual(new Number(1), new Number(2));
|
||||||
|
@ -849,7 +848,7 @@ assert.deepStrictEqual(new String('foo'), Object('foo'));
|
||||||
assert.deepStrictEqual(-0, -0);
|
assert.deepStrictEqual(-0, -0);
|
||||||
// OK
|
// OK
|
||||||
|
|
||||||
// Different zeros using the SameValue Comparison:
|
// Different zeros:
|
||||||
assert.deepStrictEqual(0, -0);
|
assert.deepStrictEqual(0, -0);
|
||||||
// AssertionError: Expected inputs to be strictly deep-equal:
|
// AssertionError: Expected inputs to be strictly deep-equal:
|
||||||
// + actual - expected
|
// + actual - expected
|
||||||
|
@ -1734,7 +1733,7 @@ changes:
|
||||||
* `message` {string|Error}
|
* `message` {string|Error}
|
||||||
|
|
||||||
Tests strict inequality between the `actual` and `expected` parameters as
|
Tests strict inequality between the `actual` and `expected` parameters as
|
||||||
determined by the [SameValue Comparison][].
|
determined by [`Object.is()`][].
|
||||||
|
|
||||||
```mjs
|
```mjs
|
||||||
import assert from 'assert/strict';
|
import assert from 'assert/strict';
|
||||||
|
@ -2026,7 +2025,7 @@ changes:
|
||||||
* `message` {string|Error}
|
* `message` {string|Error}
|
||||||
|
|
||||||
Tests strict equality between the `actual` and `expected` parameters as
|
Tests strict equality between the `actual` and `expected` parameters as
|
||||||
determined by the [SameValue Comparison][].
|
determined by [`Object.is()`][].
|
||||||
|
|
||||||
```mjs
|
```mjs
|
||||||
import assert from 'assert/strict';
|
import assert from 'assert/strict';
|
||||||
|
@ -2446,7 +2445,6 @@ argument.
|
||||||
|
|
||||||
[Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript
|
[Object wrappers]: https://developer.mozilla.org/en-US/docs/Glossary/Primitive#Primitive_wrapper_objects_in_JavaScript
|
||||||
[Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring
|
[Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring
|
||||||
[SameValue Comparison]: https://tc39.github.io/ecma262/#sec-samevalue
|
|
||||||
[`!=` 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/Inequality
|
||||||
[`===` operator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality
|
[`===` operator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality
|
||||||
[`==` operator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
|
[`==` operator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
|
||||||
|
|
Loading…
Reference in New Issue