Skip to content

Instantly share code, notes, and snippets.

@alpavlove
Created December 22, 2014 13:58
Show Gist options
  • Save alpavlove/efd0601668ed5ba76f1a to your computer and use it in GitHub Desktop.
Save alpavlove/efd0601668ed5ba76f1a to your computer and use it in GitHub Desktop.
difference between 2 objects
function diff(a,b) {
var r = {};
_.each(a, function(v,k) {
if(b[k] === v) return;
// but what if it returns an empty object? still attach?
r[k] = _.isObject(v)
? _.diff(v, b[k])
: v
;
});
return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment