Published
- 1 min read
javascript check if objects are equal
The solution for this is noted below
javascript check if objects are equal
Solution
const isEqual = (...objects) =>
objects.every((obj) => JSON.stringify(obj) === JSON.stringify(objects[0]))
// Examples
isEqual({ foo: 'bar' }, { foo: 'bar' }) // true
isEqual({ foo: 'bar' }, { bar: 'foo' }) // false
Try other methods by searching on the site. That is if this doesn’t work