From the 1.3 docs: var obj1 = {a: 0, b: 1}; var obj2 = {c: 2, d: 3}; var obj3 = {a: 4, d: 5}; var merged = Object.merge(obj1, obj2, obj3); // returns {a: 4, b: 1, c: 2, d: 5}, (obj2, and obj3 are unaltered)
merged === obj1; // true, obj1 gets altered and returned as merged object var nestedObj1 = {a: {b: 1, c: 1}}; var nestedObj2 = {a: {b: 2}}; var nested = Object.merge(nestedObj1, nestedObj2); // returns: {a: {b: 2, c: 1}} On Oct 12, 2010, at 3:39 PM, Oskar Krawczyk wrote: > Ouch. > > Yes, this should not happen. > > Can you post a ticket on lighthouse? > > On 2010-10-12, at 23:32, atom wrote: > >> bit of unexpected behavior (which might be intentional). When using >> Object.merge the objects I pass in are being altered, unlike how >> $merge used to behave. >> >> old way: >> >> var obj1 = {a: 1, b: 2, c: 3} >> var obj2 = {d: 4, e: 5, f: 6} >> var merged = $merge(obj1, obj2); >> console.log(obj1); // returns {a: 1, b: 2, c: 3} >> >> new way: >> >> var obj1 = {a: 1, b: 2, c: 3} >> var obj2 = {d: 4, e: 5, f: 6} >> var merged = Object.merge(obj1, obj2); >> console.log(obj1); // returns {a: 1, b: 2, c: 3, d: 4, e: 5, f: 6} >