var myObject = new Object(); var myObjectCopy = myObject; myObject.Name = 'alav'; // logs Name alav on both variable console.log(myObject, myObjectCopy); myObject = null; // logs myObject as null and myObjectCopy still has name 'alav' -> bcoz of reference copy console.log(myObject, myObjectCopy);
The same behavior is not replicated below.
var objA = {property: 'value'}; var pointer1 = objA;
Why is the above link copy behavior not applicable to the internal properties (property here) of an object?
objA.property = pointer1.property; β do not refer to COPY?
source share