In the above example, we declare an object: parent, with a property: prop1, set to a value: 'old value'.

On the next line, we then declare child, and set it's value to the same object as parent. In doing this, we might think that we are setting it to an instance of parent, but that is not the case! The two variables refer to the same object!

On line three then, we set prop1 in the child object to 'new value', and then finally we print out the same property of the parent object (parent.prop1).

So, what actually prints out? One might expect the prop1 property of the parent object to remain unchanged, but due to the fact that both variables are references to the same object, modifying child also modified parent! Thus, on line four, we print out the new value... "new value".

This applies just the same to GlideRecord objects on the server, since their properties are not primitive values like a string (as they would be in most client-side scripts), but GlideElement objects. Consider the following code: