Object.assign()

Dmitry Soshnikov dmitry.soshnikov at gmail.com
Wed Oct 17 21:59:20 PDT 2012


On Oct 17, 2012, at 9:34 PM, Axel Rauschmayer wrote:

>> Pardon, I missed and cannot find what is Object.assign(...), seems it's not from the latest draft. Is it just defining properties (via Object.defineProperty) on from a source to destination object? Like old-good Object.extend(...)?
> 
> Explained here: https://github.com/rwldrn/tc39-notes/blob/master/es6/2012-09/sept-18.md

I see, thanks.

So, from what I see:

1. Source should not be the one. We should support many of sources to copy all them at once:

Object.assign(dest, source1[, source2, ... sourceN])

In addition:

2. If the last parameter is boolean, then it's created as includeNonEnumerable:

Object.assign(desc, source1[, source2, ... sourceN, includeNonEnumerable);

Example;

Object.assign({a: 10}, {b: 20}, Object.defineProperties({}, {c: {value: 30}}), true); // {a: 10, b: 20, c: 30}

Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121017/63dd94f3/attachment.html>


More information about the es-discuss mailing list