[thelist] JS Object Cloning

Joshua OIson joshua at alphashop.net
Tue Mar 27 12:54:50 CST 2001


I am trying to code some JS so that I can make changes to a data structure
then commit them later.  My idea was to copy a segment from the structure
for the dialog to edit, then reinsert the changes if the user clicks same.
But, the problem is that when I try to copy the section to a temporary
place, I'm copying pointers, not clones of the data.

So, I made it automatically reconstruct the data structure on the fly using
a bunch of new Array(), but as I copy the leaves over, again, I'm getting
pointers.

Is there a clone() method?  If not, how can I make one?

Thanks in advance.

-joshua





More information about the thelist mailing list