Object.assign()

Herby Vojčík herby at mailbox.sk
Thu Oct 18 03:22:19 PDT 2012



Rick Waldron wrote:
> On Wednesday, October 17, 2012 at 10:47 PM, Axel Rauschmayer wrote:
>>>> On Wednesday, October 17, 2012 at 10:27 PM, Axel Rauschmayer wrote:
>>>>> I’m a bit skeptical about excluding non-enumerable properties for
>>>>> Object.assign(). I still find enumerability a hard concept to wrap
>>>>> my mind around, because it pops up in unexpected places. At the
>>>>> moment, it mostly matters for for...in and
>>>>> Object.keys()/Object.getOwnPropertyNames(). Does it really make
>>>>> sense to increase its role in JavaScript?
>>
>>> It's a matter of paving the cow path of least surprise. Imagine if
>>> you tried to copy the properties and values of a plain object to an
>>> object with a null prototype and all of those properties you
>>> explicitly didn't want were now present.
>>
>> But those won’t be copied, because only own properties will be copied.
>> I’d be more worried about adding non-enumerable own properties to an
>> object and those *not* being copied.
> I've always viewed enumerability as an implied intent of sharing.
> Copying non-enumerable properties is a violation of my expectations (I
> assure you, I'm not alone)

That's it. I was not able to phrase it this way, but I agree. That's why 
I was struck by making concise methods enumerable.

> Rick
>>
>> --
>> Dr. Axel Rauschmayer
>> axel at rauschma.de <mailto:axel at rauschma.de>
>>
>> home: rauschma.de <http://rauschma.de>
>> twitter: twitter.com/rauschma <http://twitter.com/rauschma>
>> blog: 2ality.com <http://2ality.com>

Herby


More information about the es-discuss mailing list