I have been trying to figure out how to make a copy of a JSON object array that can be modified without changing the original. I do see a lot of discussion regarding objects being passed as a reference by default, but I don't understand how to avoid this default behavior.
The example jQuery below is not real code, but I think it illustrates what I am trying to accomplish. Can anyone help me understand how to code the following example so that _copy can be modified with _master being left unmodified?
// Master - should never get modified
_master = [
Object { id=0, name="Charlie", city="Memphis", state="TN" },
Object { id=1, name="Steve", city="Chicago", state="IL" }
];
// Copy of Master that can be modified
_copy = _master;
// Modify _copy only - leave _master unmodified
_copy[0].name = "Charles";