Skip to content

Instantly share code, notes, and snippets.

@fzn0x
Created October 10, 2022 17:44
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 fzn0x/46045766a5155f0f360b911bfcd26c85 to your computer and use it in GitHub Desktop.
Save fzn0x/46045766a5155f0f360b911bfcd26c85 to your computer and use it in GitHub Desktop.
JS Object Diff
const diff = Object.keys(expectedObject).filter((expectedKey) => {
return !Object.keys(currentObject).includes(expectedKey);
});
console.log(diff.length); // Different in length
console.log(diff); // Missing keys in currentObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment