Analog to Object.getPropertyDescriptor() for *changing* a property value?

Axel Rauschmayer axel at
Thu Jun 23 04:56:22 PDT 2011

There are indeed a few ways around this:
Naming the prototype, using an array with a single element, etc.

On Jun 23, 2011, at 13:19 , David Bruant wrote:

> Hi,
> In a the provided example, you assign a value. Can't you just use a getter/setter pair on the prototype chain? It sounds like it would solve your use case (without the syntax sugar). On ES5 - 8.12.5 step 4 & 5, the prototype chain is climbed to look up for an accessor and if there is a setter (anywhere on the prototype chain), this setter is called. Combined with the fact that a getter naturally do the same thing for getters, you have your way to change a value "directly on the prototype chain".
> Of course, if you want to change the property descriptor on the prototype chain, none of what I said apply.
> David
> Le 21/06/2011 17:24, Axel Rauschmayer a écrit :
>> As a loose analog to the prototype-chain-traversing getPropertyDescriptor(), I would still like to have something that allows one to easily *change* properties higher up the prototype chain (e.g. to use a prototype to share state).
>> Maybe it would be enough to just have Object.getDefiningObject(obj, propName):
>> But I can also imagine syntactic sugar:
>> := "abc"
>> desugars to
>>         Object.getDefiningObject(obj, "foo").foo = "abc"

Dr. Axel Rauschmayer

axel at


More information about the es-discuss mailing list