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

Compare two arrays regardless of order is simply incorrect #513

Open
secondfry opened this issue Jun 18, 2022 · 0 comments
Open

Compare two arrays regardless of order is simply incorrect #513

secondfry opened this issue Jun 18, 2022 · 0 comments

Comments

@secondfry
Copy link

secondfry commented Jun 18, 2022

https://github.com/1milligram/1loc/blob/cecbfa239c1d6c9d527518c157b9ea20c4140c9b/snippets/array/compare-two-arrays-regardless-of-order.md?plain=1#L10

The Set object lets you store unique values of any type, whether primitive values or object references.

And an array can have duplicate values.

So it fails simplest of tests: isEqual([1], [1, 1]);
Checking for length would be incorrect too, consider such case: isEqual([1, 1, 2], [1, 2, 2]);

Also concerns from #414.

And lastly one should keep in mind that:

const a = {a: 1};
const b = {...a};
a !== b; // true

Maybe it should be documented on equality function page.

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

No branches or pull requests

1 participant