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]> 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]>:
>
> 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]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to