Le 10/04/2011 19:24, Axel Rauschmayer a écrit :
> As far as I am aware, there is no way to change a property that isn’t at the 
> beginning of the property chain, because the change will create a new 
> property there.
>
> Are there plans to change this? It would be nice to have something akin to 
> class methods (without accessing the prototype via some other, e.g. global, 
> reference).
The ES5 Object.* API already provides everything you need to manipulate
all properties you can find in an object (own or inherited).
The "lowest-level" method to change the value of an own property is
Object.defineProperty. This method can also be used to "re-configure" a
property (make it non-configurable, change its enumerablity, change its
"type" (data/accessor), change its writability if it is described by a
data property descriptor). For examples, I recommend reading the MDN doc
[1].
In order to access a reference to the prototype of an object, you can
use Object.getPrototypeOf. Using both, you have enough power to achieve
any change you could think of on any property of an object (own or
inherited).
Few platforms implement both at the moment. See [2] for reference.
As Dmitry said, inherited accessor properties could be enough for what
you need.

David

[1]
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty
[2] http://kangax.github.com/es5-compat-table/
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to