is-equal-shallow
is-equal-shallow copied to clipboard
The code should not check if value is primitive or not
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?