Skip to content

Instantly share code, notes, and snippets.

@sakshstore
Created September 2, 2022 09:27
Show Gist options
  • Save sakshstore/f41a84a0e58c5e7aa655570bad0ab44b to your computer and use it in GitHub Desktop.
Save sakshstore/f41a84a0e58c5e7aa655570bad0ab44b to your computer and use it in GitHub Desktop.
const compareObjects = (obj1, obj2) => {
const c = Object.keys(obj1),
n = Object.keys(obj2);
return c.length === n.length && c.every((c) => obj1[c] === obj2[c]);
};
// Usage
compareObjects({ a: 1, b: 2 }, { a: 1, b: 2 }); // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment