Created
March 9, 2021 04:52
-
-
Save huytd/a1ce11e07c7c6eb6332832df72aebcee to your computer and use it in GitHub Desktop.
Deep compare with sorted keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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