Path: csiph.com!weretis.net!feeder4.news.weretis.net!feeder5.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Object oriented programming Date: Tue, 9 Jan 2018 00:12:16 +0100 Organization: solani.org Lines: 38 Message-ID: References: <3c2333ff-00fe-4087-ab49-f52d0546b29b@googlegroups.com> <5d1ca5ad-55c3-43b5-b3d0-617e3150355e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: solani.org 1515453133 1921 eJwVzMENwDAIBMGWbOAuUA4Y038JSZ6rkRbKzfMYQcNgav+dOCKjHXVUbZYdi56Pky70juv3uoiVSk7nVn3Sk1UZHUTIt8XKvpCaYmH5ML30BbN6Huc= (8 Jan 2018 23:12:13 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Mon, 8 Jan 2018 23:12:13 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 In-Reply-To: X-User-ID: eJwNyrEBwDAIA7CXUoINPcc08P8JzaRF2Hz4hRN0DCZsWkwbvtXJq0k5y7fqnuMlLHkM03GaPyMDEUE= Content-Language: de-DE X-NNTP-Posting-Host: eJwFwYEBACAEBMCVSP8yDsr+I3QHo7J9E9wYTJJuYTsT15Znxl0GqK5SmkRsWdOXc7CX49X00zxZ3hUlkHoiVGeE3yMp8BfdmT5zaOcDYWEdyA== Cancel-Lock: sha1:NbSGvIRbL7ucrj5AFWUV6AOeNbM= Xref: csiph.com comp.lang.javascript:34525 On 08.01.2018 at 10:39, John G Harris wrote: > On Sun, 7 Jan 2018 15:26:21 +0100, "Christoph M. Becker" > wrote: > >> On 07.01.2018 at 15:13, John G Harris wrote: >> >>> newObject and oldObject have different prototype objects; newObject >>> can't be a clone of oldObject. >> >> You may prefer >> >> let newObject = Object.assign({}, oldObject); > > Um. Object.assign doesn't copy non-enumerable properties, prototype, > or internal slots. It's a restricted clone operation. For instance, it > won't clone an Array object. ACK. However, it seems that we both missed the point, namely that the article's[1] definition ("[…] instead a prototype can be cloned resulting in another concrete and fully functional object.") might simply be too strict or is using the word "clone" in a very broad sense. Interestingly, Wikipedia defines Prototype-based programming as[2]: | Prototype-based programming is a style of object-oriented programming | in which behaviour reuse (known as inheritance) is performed via a | process of reusing existing objects via delegation that serve as | prototypes. That fits well to Object.prototype.create() and also to the spirit of the article (at least for me). [1] [2] -- Christoph M. Becker