Skip to content

Instantly share code, notes, and snippets.

@huytd
Created March 9, 2021 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huytd/a1ce11e07c7c6eb6332832df72aebcee to your computer and use it in GitHub Desktop.
Save huytd/a1ce11e07c7c6eb6332832df72aebcee to your computer and use it in GitHub Desktop.
Deep compare with sorted keys
const stringify = o => JSON.stringify(o, Object.keys(o).sort());
const eq = (a, b) => stringify(a) === stringify(b);
const a = {name: "Jack", age: 20};
const b = {age: 20, name: "Jack"};
debug(eq(a, b));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment