Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep equality including keys is not documented #60

Closed
planttheidea opened this issue Dec 5, 2021 · 0 comments · Fixed by #62
Closed

Deep equality including keys is not documented #60

planttheidea opened this issue Dec 5, 2021 · 0 comments · Fixed by #62
Assignees

Comments

@planttheidea
Copy link
Owner

When doing a deep equality comparison, the deep equality of keys as well as values are used for Map. This is intentional, as it allows for comparisons like this:

const mapA = new Map([[{ foo: 'bar' }, { bar: 'baz' }]]);
const mapB = new Map([[{ foo: 'bar' }, { bar: 'baz' }]]);

deepEqual(mapA, mapB); // true

Since the spec of Map lookups use SameValueZero for keys, it is not obvious that this is the case. The documentation should call out this feature and its reasoning so developers are aware.

Originally called out in this PR by @g-traub .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant