If you want the comparison to be both deep and tolerant of objects and arrays, then this tool, which I wrote some time ago, can be useful:
https://github.com/danski/spahql/blob/master/src/SpahQL.DataHelper.js#L18
SpahQL.DataHelper.compare( {"a": "aval", "b": "bval", "c": "cval", "arr": [0,1,2]}, {"a": "modified", "c": "cval", "d": "added", "arr": [0,1,2,3]} ); // -> {"/": "~", "/a": "~", "/b": "-", "/d": "+", "/arr": "~", "/arr/3": "+"}
source share