Skip to content

Commit 1e795f3

Browse files
niedzielskitrentmwillis
authored andcommitted
Doc: deepEqual() checks strict inherited equality
Via comments on https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Popups/+/488977/1//COMMIT_MSG@10.
1 parent 8b645f7 commit 1e795f3

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

docs/assert/deepEqual.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
layout: default
33
title: deepEqual
4-
description: A deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates and functions.
4+
description: A deep recursive strict comparison, working on primitive types, arrays, objects, regular expressions, dates and functions considering all own and inherited properties.
55
categories:
66
- assert
77
redirect_from:
@@ -10,7 +10,7 @@ redirect_from:
1010

1111
## `deepEqual( actual, expected [, message ] )`
1212

13-
A deep recursive comparison, working on primitive types, arrays, objects, regular expressions, dates and functions.
13+
A deep recursive strict comparison, working on primitive types, arrays, objects, regular expressions, dates and functions considering all own and inherited properties.
1414

1515
| name | description |
1616
|--------------------|--------------------------------------|
@@ -24,6 +24,8 @@ The `deepEqual()` assertion can be used just like `equal()` when comparing the v
2424

2525
[`notDeepEqual()`](/assert/notDeepEqual) can be used to explicitly test deep, strict inequality.
2626

27+
[`propEqual()`](/assert/propEqual) can be used to explicitly test deep, strict equality but only considering own properties. `deepEqual()` compares all inherited properties.
28+
2729
### Examples
2830

2931
Compare the value of two objects.
@@ -34,3 +36,17 @@ QUnit.test( "deepEqual test", function( assert ) {
3436
assert.deepEqual( obj, { foo: "bar" }, "Two objects can be the same in value" );
3537
});
3638
```
39+
40+
```js
41+
QUnit.test( 'deepEqual failing test', function( assert ) {
42+
assert.deepEqual( {
43+
a: 'Albert',
44+
b: 'Berta',
45+
num: 123
46+
}, {
47+
a: 'Albert',
48+
b: 'Berta',
49+
num: '123' // Fails: the number `123` is not strictly equal to the string `'123'`.
50+
} );
51+
} );
52+
```

0 commit comments

Comments
 (0)