Skip to content

Conversation

hamzakargin
Copy link

Updated assert.deepStrictEqual docs to explicitly mention that object constructors are included in the comparison. This clarifies behavior consistent with util.isDeepStrictEqual and helps prevent confusion when comparing derived objects or proxy instances.

Updated `assert.deepStrictEqual` docs to explicitly mention that object constructors are included in the comparison.
This clarifies behavior consistent with `util.isDeepStrictEqual` and helps prevent confusion when comparing derived objects or proxy instances.
@nodejs-github-bot nodejs-github-bot added assert Issues and PRs related to the assert subsystem. doc Issues and PRs related to the documentations. labels Oct 14, 2025
* [Type tags][Object.prototype.toString()] of objects should be the same.
* Only [enumerable "own" properties][] are considered.
* Object constructors are also compared to ensure that instances are strictly deep-equal.
This means that even if two objects share the same prototype and properties, differing constructors will result in inequality.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we should explain how things work and instead just explain what happens.

Suggested change
This means that even if two objects share the same prototype and properties, differing constructors will result in inequality.

both sides are {NaN}.
* [Type tags][Object.prototype.toString()] of objects should be the same.
* Only [enumerable "own" properties][] are considered.
* Object constructors are also compared to ensure that instances are strictly deep-equal.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually not always true, e.g., for null prototypes, there is no constructor.

I am not sure how to word it appropriately right now.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @BridgeAR!
I’ve simplified the sentence to describe the behavior only, as suggested.

@Blancacamarena
Copy link

Blancacamarena commented Oct 22, 2025 via email

@hamzakargin hamzakargin requested a review from BridgeAR October 22, 2025 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assert Issues and PRs related to the assert subsystem. doc Issues and PRs related to the documentations.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants