Object.equals() and Object.clone()

Frankie Bagnardi f.bagnardi at gmail.com
Tue Nov 15 04:13:52 UTC 2016


I guess it could throw if it's unable to clone something. This would
include *any* class without `Symbol.clone`. The error messages would need
to be outstanding for it to be practical. Like showing the path to the
thing that can't be cloned and the name of the constructor.


On Mon, Nov 14, 2016 at 9:01 PM, Michael Theriot <
michael.lee.theriot at gmail.com> wrote:

> I think you'd definitely need to call the constructor for classes because
> of scoped variables (e.g. scoped weakmap for private properties).
>
> I would like a way to compare simple objects like identical arrays though.
>
> On Mon, Nov 14, 2016 at 7:58 PM, Frankie Bagnardi <f.bagnardi at gmail.com>
> wrote:
>
>> It's pretty hard to decide how these behave, specifically with custom
>> classes. Focusing on Object.clone...
>>
>> - with classes do you call the constructor, and with what arguments?
>> - HTMLElement and sub classes can't be constructed directly, what happens
>> with them?
>> - do you copy internal properties? this would make it hard to polyfill
>> - how does it behave with getters and setters?
>> - with regular expressions do you copy the lastIndex?
>>
>> Most of those apply to Object.equals also.
>>
>>
>>
>> On Mon, Nov 14, 2016 at 6:25 PM, Kevin Barabash <kevinb at khanacademy.org>
>> wrote:
>>
>>> It would be nice if deep equality checking and deep cloning of objects
>>> was included in the standard library.  Has there been any proposals around
>>> including these in the past?
>>>
>>> – Kevin
>>>
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20161114/bc2e4e9a/attachment.html>


More information about the es-discuss mailing list