Non-standard
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.
Deprecated
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.
Summary
The __lookupGetter__
method returns the function bound as a getter to the specified property.
Syntax
obj.__lookupGetter__(sprop)
Parameters
-
sprop
- A string containing the name of the property whose getter should be returned.
Description
If a getter has been defined for an object's property, it's not possible to reference the getter function through that property, because that property refers to the return value of that function. __lookupGetter__
can be used to obtain a reference to the getter function.
It is now possible to do this in a standardized way using Object.getOwnPropertyDescriptor()
and Object.getPrototypeOf()
.
Examples
var obj = { get foo() { return Math.random() > 0.5 ? "foo" : "bar"; } }; obj.__lookupGetter__("foo") // (function (){return Math.random() > 0.5 ? "foo" : "bar"})
Specifications
Not part of any specifications.
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | ? | (Yes) | (Yes) |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | ? | ? | (Yes) |