This question already has an answer here:
Hi i have use the following code to create the object
var parent = {};
parent["Task name"] = "Task " + ++x;
parent["Start time"] = "01/03/2013";
parent["End time"] = "01/08/2013";
parent["Duration"] = "5 days";
parent["Status"] = Math.round(Math.random() * 100);
How to clone / take the copy of the object using JavaScript Code . Is there any other way to achieve this?
Try this with jQuery:
The simplest way to clone an object is using the following function:
This creates a basic copy of the object, do note though that this does not create a deep copy, only a shallow one.
The most basic way is as follows :
Works in this case since all values are of primitive types.