Skip to content

Instantly share code, notes, and snippets.

@andrIvash
Created November 22, 2019 07:37
Show Gist options
  • Save andrIvash/40c85d458c529b9f00ed4ccea6060d34 to your computer and use it in GitHub Desktop.
Save andrIvash/40c85d458c529b9f00ed4ccea6060d34 to your computer and use it in GitHub Desktop.
get and show diff between object
function getObjectDiff(obj1, obj2) {
const diff = Object.keys(obj1).reduce((result, key) => {
if (!obj2.hasOwnProperty(key)) {
result.push(key);
} else if (isEqual(obj1[key], obj2[key])) {
const resultKeyIndex = result.indexOf(key);
result.splice(resultKeyIndex, 1);
}
return result;
}, Object.keys(obj2));
return diff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment