On Thu, Oct 18, 2012 at 10:13 AM, Rick Waldron <waldron.r...@gmail.com>wrote:

>
>
> On Thu, Oct 18, 2012 at 12:59 AM, Dmitry Soshnikov <
> dmitry.soshni...@gmail.com> wrote:
>
>>
>> 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])
>>
>
>
> I had originally hoped for this, but we reached consensus
> on Object.assign(dest, source) to allow for a possible descriptor map param.
>
> The pattern you're looking for can be achieved as....
>
> [ defaults, options, overrides ].reduce(Object.assign, {});
>
>
>
>>
>> In addition:
>>
>> 2. If the last parameter is boolean, then it's created as
>> includeNonEnumerable:
>>
>> Object.assign(desc, source1[, source2, ... sourceN, includeNonEnumerable);
>>
>
>
> Boolean parameters are a non-starter and would conflict with the desire to
> have an optional third "default descriptor map" parameter.
>

In general, it makes sense to be careful about adding new parameters,
because it prevents useful extensions in the future.


>
>
> Rick
>
>
>>
>> Example;
>>
>> Object.assign({a: 10}, {b: 20}, Object.defineProperties({}, {c: {value:
>> 30}}), true); // {a: 10, b: 20, c: 30}
>>
>> Dmitry
>>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
Yehuda Katz
(ph) 718.877.1325
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to