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

The code should not check if value is primitive or not #4

Open
lsmoura opened this issue May 4, 2018 · 1 comment
Open

The code should not check if value is primitive or not #4

lsmoura opened this issue May 4, 2018 · 1 comment

Comments

@lsmoura
Copy link

lsmoura commented May 4, 2018

JavaScript non-primitive objects are memory references. So, if variables in two different objects point to the same memory reference, it should return true.

Take this code for example:

const shallow = require('is-equal-shallow');

const o = { foo: 'bar' };

const a = { a: o };
const b = { a: o };

console.log('a shallow-equal b?', shallow(a, b));

A and B are exactly the same, since the a key points to the same object. It's different from calling

const shallow = require('is-equal-shallow');

const a = { a: { foo: 'bar' } };
const b = { a: { foo: 'bar' } };

console.log('a shallow-equal b?', shallow(a, b));

Because they point to different objects.

Should the isPrimitive check be dropped from the test?

@jonschlinkert
Copy link
Owner

why should the primitive check be dropped? What is the bug that's happening?

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

2 participants