On Fri, Oct 7, 2011 at 11:08 AM, Axel Rauschmayer <[email protected]> wrote:

>
>> I don’t see a simple way of “fixing” (property descriptors do have their
>>> uses) Object.create().
>>>
>>
>> Just allow the second argument to be property descriptor *or* object.
>>
>>
>> Problem: property descriptors are indistinguishable from normal objects,
>> they *are* normal objects.
>>
>
> If you pass a normal object to object.Create() you get an error message.
> Clearly they can be distinguished.
>
>
> var obj = Object.create(proto, { p: { value: 42 } })
>
> How would JS distinguish between the property descriptor { value: 42 } and
> an object whose property "value" has the value 42?
>

I would interpret this as a descriptor; if the dev wanted a property they
would say {p:42};

But let's give up on this line, it will never be accepted here. Let's
concentrate on how to create objects given that Object.create(proto) gives
an empty object with a prototype of |proto|. Could Object.extend() be
defined so devs can combine it with Object.create()?

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

Reply via email to