I know Object.defineProperty
is lots of fun and a great replacement for __defineGetter__
and __defineSetter__
nonstandard APIs, but is there a similar counterpart for __lookupGetter__
? Or some way of achieving a similar thing?
I'm not sure of the __lookupGetter__
semantics but ES5 provides a new API Object.getOwnPropertyDescriptor
that gives you a descriptor object containing the attributes of a property and either its value
or its get
and/or set
functions.
eg.
Object.getOwnPropertyDescriptor("foo", {get foo() { return 5} }).get
Will give you the getter function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With