Property descriptors as ES6 Maps

David Bruant bruant.d at
Thu Nov 1 06:25:33 PDT 2012

Le 01/11/2012 10:37, Tom Van Cutsem a écrit :
> On the other hand, as so carefully explained by Allen, there currently
> isn't really an issue with the mapping between property descriptors
> and objects: at all the boundary points, we make sure to properly
> convert descriptors into well-behaved objects and vice versa.
What do you think of the idea of exposing objects that would be
well-behaved as property descriptor by construction? These objects can
be used both internally and at trap boundaries.
It wouldn't be compulsory to preserve backward compat, but just more

The name I've used in my answer to Allen is awful, but it can obviously
be changed :-) (maybe PropDesc or PropertyDescriptor?)

> As you point out yourself, making the change from objects to maps
> implies a bunch of backwards compat. issues. My position is that doing
> the object->map refactoring at this stage would entail a lot of work
> for very little gain.
I agree.

> Finally, remember that property descriptors-as-objects really leverage
> the object literal notation (i.e. I can create a property descriptor
> by just writing "{value:42,writable:true}". I don't think there is a
> corresponding sweet syntax for literal maps?
I don't think maps are a good idea any longer, but for this point, I
think the following has been suggested:
Map({value:42, writable:true})
(If it hasn't yet, it sounds like a fanstastic idea to initialize ES6 maps!)

The constructor I have proposed could have an equivalent initialization
Object.defineProperty({}, 'a', PropDesc({value:42, writable:true}))


More information about the es-discuss mailing list