[Proto-Scripty] Re: How to make an independent copy of an object?

2008-10-09 Thread kangax
On Oct 8, 2:27 pm, buda <[EMAIL PROTECTED]> wrote: > I really need to have a separate copy of an object - they are small > and it needn't to have heavy computations and consume a lot of memory I'm sure there are obvious drawbacks (that I can't think of right now) but what about using json for sto

[Proto-Scripty] Re: How to make an independent copy of an object?

2008-10-08 Thread buda
I really need to have a separate copy of an object - they are small and it needn't to have heavy computations and consume a lot of memory On 8 окт, 17:16, "T.J. Crowder" <[EMAIL PROTECTED]> wrote: > > True use-cases for deep-cloning are actually pretty rare. > > I'll second that. > > > I'm not s

[Proto-Scripty] Re: How to make an independent copy of an object?

2008-10-08 Thread T.J. Crowder
> True use-cases for deep-cloning are actually pretty rare. I'll second that. > I'm not sure what you are attempting to do here, but there's most > certainly a better way of doing it without needing deep-cloning. I think I'd go with "probably". :-) But yeah, buda, you might want to step back a

[Proto-Scripty] Re: How to make an independent copy of an object?

2008-10-08 Thread Tobie Langel
True use-cases for deep-cloning are actually pretty rare. When bumping into such an issue, it's usually a good idea to look for a better coding pattern rather than to add complexity, augment memory consumption and worsen the performance by bringing out the big guns. I'm not sure what you are att

[Proto-Scripty] Re: How to make an independent copy of an object?

2008-10-08 Thread T.J. Crowder
Hi, Object.clone is documented as being a shallow copy: http://www.prototypejs.org/api/object/clone "Deep" cloning is more complicated than it seems at first. A naive version would be along these lines: Object.extend(Object, { deepClone: function(source) { var result; var p