@@ -1553,19 +1553,49 @@ inspect.defaultOptions.maxArrayLength = null;
15531553console .log (arr); // logs the full array
15541554```
15551555
1556- ## ` util.isDeepStrictEqual(val1, val2) `
1556+ ## ` util.isDeepStrictEqual(val1, val2[, options] ) `
15571557
15581558<!-- YAML
15591559added: v9.0.0
1560+ changes:
1561+ - version: REPLACEME
1562+ pr-url: https://github.com/nodejs/node/pull/00000
1563+ description: Added `options` parameter to allow skipping prototype comparison.
15601564-->
15611565
15621566* ` val1 ` {any}
15631567* ` val2 ` {any}
1568+ * ` options ` {Object}
1569+ * ` skipPrototypeComparison ` {boolean} If ` true ` , prototype and constructor
1570+ comparison is skipped during deep strict equality check. ** Default:** ` false ` .
15641571* Returns: {boolean}
15651572
15661573Returns ` true ` if there is deep strict equality between ` val1 ` and ` val2 ` .
15671574Otherwise, returns ` false ` .
15681575
1576+ By default, deep strict equality includes comparison of object prototypes and
1577+ constructors. When ` options.skipPrototypeComparison ` is ` true ` , objects with
1578+ different prototypes or constructors can still be considered equal if their
1579+ enumerable properties are deeply strictly equal.
1580+
1581+ ``` js
1582+ const util = require (' node:util' );
1583+
1584+ function Foo (a ) { this .a = a; }
1585+
1586+ function Bar (a ) { this .a = a; }
1587+
1588+ const foo = new Foo (1 );
1589+ const bar = new Bar (1 );
1590+
1591+ // Different constructors, same properties
1592+ console .log (util .isDeepStrictEqual (foo, bar));
1593+ // false
1594+
1595+ console .log (util .isDeepStrictEqual (foo, bar, { skipPrototypeComparison: true }));
1596+ // true
1597+ ```
1598+
15691599See [ ` assert.deepStrictEqual() ` ] [ ] for more information about deep strict
15701600equality.
15711601
0 commit comments