DEV Community

Discussion on: Deep Equality checking of Objects in Vanilla JavaScript 👨‍👦

Collapse
mohnnadbahaa profile image
Mohannad Bahaa

i think you can use JSON.stringify the both objects then you can compare it !
the only issue here you need to catch JSON.stringify error !

Collapse
amaslakov profile image
Aleksei Maslakov

What if you have objects with different field order? Like { foo: 'bar', baz: 42 } vs { baz: 42, foo: 'bar' }. How do you handle that with JSON.stringify?