Performs a deep-diff comparison between two objects
and returns a hash mapping all keys from obj1
and obj2
to whether or not they were changed.
(A key is mapped to true
if there are differences, false
otherwise).
It does not matter which order you pass the parameters in; the
returned object will remain the same.
Example:
var newModelAttributes = {
a: 1,
b: {create: true, edit: false},
c: 'test',
d: {a: 'b', c: {d: true}}
};
var oldModelAttributes = {
a: 1,
b: {create: true},
c: undefined,
e: [1, 2]
};
_.changed(newModelAttributes, oldModelAttributes);
// {a: false, b: true, c: true, d: true, e: true}