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

Object with index as keys should not equal array #17

Closed
a-b-r-o-w-n opened this issue Aug 17, 2015 · 2 comments · Fixed by inspect-js/node-deep-equal#65
Closed

Object with index as keys should not equal array #17

a-b-r-o-w-n opened this issue Aug 17, 2015 · 2 comments · Fixed by inspect-js/node-deep-equal#65

Comments

@a-b-r-o-w-n
Copy link

expect({ 0: 'hello', 1: 'world' }).toEqual([ 'hello', 'world' ]);

I don't think this should pass, but it does. Is there something I am missing, or is this not intended?

@mjackson
Copy link
Owner

JavaScript arrays are actually objects (with special semantics). I see no reason why that test shouldn't pass.

@aaronjensen
Copy link

Node core no longer agrees: https://github.com/nodejs/LTS/wiki/Breaking-changes-between-v0.12-and-next-LTS-release#assert-check-object-prototype-in-assertdeepequal

nodejs/node#621

Object.getPrototypeOf([0]) === Object.getPrototypeOf({'0': 0})
false

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

Successfully merging a pull request may close this issue.

3 participants