And maybe there should be a Object.move for value types...

From: Frankie Bagnardi <[email protected]<mailto:[email protected]>>
Date: Tuesday, June 10, 2014 at 2:47 PM
To: Alex Kocharin <[email protected]<mailto:[email protected]>>
Cc: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: Object copy

I'd like Object.merge(source, dest), and Object.clone(source).

Object.clone would be best if it cloned almost any object, like more advanced 
clone functions.  This includes plain objects, arrays, instances of classes 
(preserving base class, etc.), regExp, promise, and ideally DOM nodes in 
browsers (along with anything else that can be cloned).  If something can't be 
cloned, including primitives and functions, it should throw an error.

Object.merge would be a much simpler "copy enumerable own properties" function.

Object.merge({a: 1}, {}); and Object.clone({a: 1}); would be equivalent, but 
they differ in most other cases.





On Tue, Jun 10, 2014 at 10:38 AM, Alex Kocharin 
<[email protected]<mailto:[email protected]>> wrote:

Object.create() ?

It's not exactly cloning, but it'll probably work better than cloning in most 
cases.


10.06.2014, 20:33, "Maxime Warnier" <[email protected]<mailto:[email protected]>>:
Hi All

Do you know if it is planned or maybe in discussion for ES7 to have a simple 
clone system on objects ?

There are different notations, from :

 - jquery

Object.clone( [withDataAndEvents ] [, deepWithDataAndEvents ] )

( but only for DOM element )

 - underscore

_.clone(object)

( return the cloned object )

 - angular

angular.copy(source, [destination]);

(return the object, same as underscore, or copy into an optional destination )


Maybe an Object.copy([options?]) would be interesting ?




Maxime


Maxime Warnier
@maxdow
,

_______________________________________________
es-discuss mailing list
[email protected]<mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[email protected]<mailto:[email protected]>
https://mail.mozilla.org/listinfo/es-discuss



---------------------------------------------------------------------
This e-mail is intended only for the use of the addressees.  Any copying, 
forwarding, printing or other use of this e-mail by persons other than the 
addressees is not authorized.  This e-mail may contain information that is 
privileged, confidential and exempt from disclosure. If you are not the 
intended recipient, please notify us immediately by return e-mail (including 
the original message in your reply) and then delete and discard all copies of 
the e-mail. 

Thank you.

---------------------------------------------------------------------

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to