Hy guys thanks for checking out my question. I am investigating/researching something since 2 days, and I can not find out, why does it work, as it works.
So here is the code:
var obj = {
prop1 : "12",
prop2 : {
prop3 : 24,
prop4 : "mother"
}
}
newObj = obj;
console.log(newObj);
console.log(obj);
newObj.prop2 = 1;
So I define here an object literal which in the creation phase of the build up of execution context, will get to be a key of the variable object of the current executionContextObject and than will be set to undefined.
And I change the obj.prop2-s value at the end of the code, but altough I change it at the end of the code my console.log() expressions, before the expression of:"newObj.prop2 = 1;" will show the muted properties.
What I dont uderstand here is, why this change - "newObj.prop2 = 1;" at the end of the code -, takes place before the interpreter arrives that line:"newObj.prop2 = 1;" and the console.log expressions are showing a change, which should happen just after them.
Thanks for reading my question until know. If you just say what topic should I investigate to get an understanding about this phenomenon, would be enormously helpful.
Thanks a lot guys