Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // write a function that compare 2 js objects and return the diff?
- // Example:
- // assume that values are objects or strings
- var obj1 = {
- prop1: 'prop1',
- prop2: 'prop2',
- prop4: {
- a:'a',
- b:'b'
- }
- };
- var obj2 = {
- prop2: 'prop2 modified',
- prop3: 'new prop foo',
- prop4:{
- b:'v',
- c:'c'
- }
- };
- diff(obj1, obj2);
- // should return the following
- // {
- // added: ["prop3", “prop4.c”],
- // deleted: ["prop1", “prop4.a”],
- // modified: ["prop2", “prop4.b”]
- // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement