Skip to content

Instantly share code, notes, and snippets.

@leonidkuznetsov18
Last active May 27, 2020 19:45
Show Gist options
  • Save leonidkuznetsov18/5797a20ca2f9e8ecbac11f3f896e6851 to your computer and use it in GitHub Desktop.
Save leonidkuznetsov18/5797a20ca2f9e8ecbac11f3f896e6851 to your computer and use it in GitHub Desktop.
Deep diff between two object
function difference(object, base) {
return _.transform(object, (result, value, key) => {
if (!_.isEqual(value, base[key])) {
result[key] = _.isObject(value) && _.isObject(base[key]) ? difference(value, base[key]) : value;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment