ToPropertyDescriptor and [[DefineOwnProperty]], regarding Object.defineProperty

Jim Blandy jimb at mozilla.com
Mon Jun 1 13:45:13 PDT 2009


Object.defineProperty lets one change the Writeable attribute with:

   Object.defineProperty(obj, prop, ({writeable:state}))

The way that's currently defined, we just convert that one-property 
object to a property descriptor and pass it to [[DefineOwnProperty]].  
It's a nice way to change a single attribute; the rationale paper[0] 
talks about this.  If property descriptors couldn't omit the other 
fields, how would this work?

That is, of course it can be made to work; one does a 
getOwnPropertyDescriptor, modifies the field, and then writes it back.  
But what I wrote above is pretty sweet.

[0] Proposed ECMAScript 3.1 Static Object Functions: Use Cases and 
Rationale, linked to from 
http://wiki.ecmascript.org/doku.php?id=es3.1:es3.1_proposal_working_draft



More information about the es-discuss mailing list