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

Feature request: ignore undefined values #127

Open
tmtron opened this issue Aug 4, 2021 · 2 comments
Open

Feature request: ignore undefined values #127

tmtron opened this issue Aug 4, 2021 · 2 comments

Comments

@tmtron
Copy link

tmtron commented Aug 4, 2021

in version 3.1.3 of the library the following comparison returns false

equal({ a: undefined }, {})

That's quite a surprise for me, but since there are test-cases for this case, I guess it works as expected.

It would be good to have an option to ignore undefined values.

@dalepo
Copy link

dalepo commented Apr 10, 2022

This comparison has to be falsy since your second object does not contain the a property, its working as intended imo.

@tmtron
Copy link
Author

tmtron commented Apr 11, 2022

Yes, technically they are different, but semantically they may be equal: i.e. a missing property and a property with the value undefined often mean the same thing: For example, look at the output of JSON.stringify()

  • JSON.stringify({}) = {}
  • JSON.stringify({a:undefined}) = {}

The result is the same. So in this case, so equals should return true.

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