Deep cloning objects defined by JSON.

Xavier MONTILLET xavierm02.net at gmail.com
Sun Jan 29 13:09:46 PST 2012


I think it should keep it. Douglas did something to allow cyclic
references ( https://github.com/douglascrockford/JSON-js/blob/master/cycle.js
) and he probably wouldn't have done that if it had no use. Plus
you're talking of cloning data structures and a graph is one.

And if you do not allow cyclic references, you still have to do
something about it. Ignoring the properties will probably make devs
wonder why this property isn't cloned and throwing an error is, IMHO,
no the kind of behavior you want.

On Sun, Jan 29, 2012 at 9:56 PM, Peter van der Zee <ecma at qfox.nl> wrote:
> On Sun, Jan 29, 2012 at 7:50 PM, Xavier MONTILLET
> <xavierm02.net at gmail.com> wrote:
>> With your last two implementations, you don't keep cyclic references.
>
> I did not intend to. In fact, my intention was to have a "clean"
> object with just structure (objects and arrays) and primitives.
> Nothing else, especially nothing invisible (like references, object
> instances or attributes). You can save that fancy stuff for
> Object.clone :)
>
> - peter


More information about the es-discuss mailing list