Why does modifying nested properties in a copied object affect the original but not its reference