Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap

Feedback on: Site Map, August 29, 2002 at 12:38:35:

You are here: irt.org | About | Feedback | 4112 [ previous next ]

Feedback on:
Site Map

Sent by
Fran Morabito on August 29, 2002 at 12:38:35:

Very worth reading

Thanks for the code used to clone Javascript objects (FAQ879). It works great! I found one problem with it if you have an object with an array as a member. I added code to check if the object has a length property to it. If so it creates an array and appends the subsequent data. Maybe this would help someone else. Check the following modifications.

function CloneObject(Obj)
for(var i in Obj)
if(typeof Obj[i] == "object")
this[i] = new Array();
for(var j=0; j < Obj[i].length; j++)
if(typeof Obj[i][j] == "object")
this[i][j] = new CloneObject(Obj[i][j]);
this[i][j] = Obj[i][j];
} else
this[i] = new CloneObject(Obj[i]);
} else {
this[i] = Obj[i];

Other feedback on 'Site Map' - show all

©2018 Martin Webb