Path: csiph.com!aioe.org!news.mb-net.net!open-news-network.org!.POSTED.35.233.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Cloning an object Date: Fri, 06 Jul 2018 00:32:59 +0200 Organization: PointedEars Software (PES) Lines: 34 Message-ID: <2080670.ElGaqSPkdT@PointedEars.de> References: <1620852.VI2in3QvqR@PointedEars.de> <9909bfec-c6e7-2a4a-2a54-ec9f271691c8@PointedEars.de> <4395113.31r3eYUQgx@PointedEars.de> <506b67da-b086-3d0e-5985-d0f8214da432@PointedEars.de> <5399415.lOV4Wx5bFT@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit Injection-Info: gwaiyur.mb-net.net; posting-host="35.233.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch:178.197.233.35"; logging-data="18429"; mail-complaints-to="abuse@open-news-network.org" User-Agent: KNode/4.14.2 Cancel-Lock: sha1:mrPQy0iDI8Z5F9UB4F5dN9jcZMg= X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. On 05/07/2018 23:35, Thomas 'PointedEars' Lahn wrote: >> In a way it both works as designed and in another it is b0rken as >> designed: >> >> You forgot to tell clone() to make a deep copy – as did I in the code >> above (but not in my later tests) :) > > No, I didn't. I use a bit different way of making a copy of object and > I've used your approach to see if it passes all unit tests I have. > Because of not passing tests I've shared here the results. That *your* code, that *you* *think* is implementing my approach, which you do not show, is not working as you expect, does not invalidate *my* approach and *my* code that I wrote to implement it. Even though my originally posted code has that bug that *I* have found as you forced me to look at it again: When *actually* called with deepCopy === true, it only copies *one* level deep. > The only way that works to me is to use "map" and create a new Array. > Then object in the array item is like a real copy. Look more carefully at the code again, read my follow-up again, and do read my other follow-up; you appear to have the common misconception of "nested objects" in ES. HTH -- PointedEars FAQ: | | Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.