I have a JSON literal as follows:
var json_1 = {
"name": "Tim",
"toys": ["ball", "bat", "lego"]
};
Now I clone this as follows:
var json_2 = json_1;
If I remove a toy from json_1
(using splice()
)the same seems to be getting removed from json_2
.
How do I create a copy without them being dependent on each other?