I want to clone an object in Javascript. I have:
iPath = function () { this.heading = 0; this.path = []; };
loop = new iPath();
I know with jQuery I can do something like:
cloneLoop = $.extend(true, {}, loop);
but than
assert(cloneLoop instanceof iPath, "fails because loop is not an iPath");
How can i do a deep clone fulfilling last assert statement?
How about this:
…though I’m not sure if you’d want to do a deep copy. I’d think this would be better: