0
var obj1 = new obj();
var obj2 = obj1.clone();

obj2.BusinessLine = businessLine2;
console.log(obj2.BusinessLine); // businessLine2
console.log(obj1, obj2); // businessLine1, businessLine1

obj2.loadClone(obj1); //irrelevant

console.log(obj1, obj2);

jsfiddle here. I define a new object, clone it with $.extend and change one of the clone's properties that links to an object. console.log(clone.property) shows the new value but console.log(clone) shows the old value.

Bogdan
  • 1,869
  • 6
  • 24
  • 53
  • 2
    Your `//irrelevant` line is actually very relevant: the Javascript console on most browsers logs a *live* view of objects, which is updated as they change. Since you revert `obj2` back to `obj1`, by the time you check the console, the view has been updated and the second and third lines logged are identical. – Frédéric Hamidi Oct 03 '14 at 09:19
  • oh damn, how did I forget about that... This always bites me in the backside when i'm debugging. – Bogdan Oct 03 '14 at 09:20
  • If you do individual console.log for the objects before and after the LoadClone you will see it works perfectly. Before loadClone, BusinessLine1 and 2 shows up in obj1 or obj2. Once you load clone, both is BusinessLine1, because you loaded obj1 into obj2 – user3036342 Oct 03 '14 at 09:21

0 Answers0