弃用
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the
兼容性表格
at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
__lookupGetter__
method returns the function bound as a getter to the specified property.
obj.__lookupGetter__(sprop)
sprop
A string containing the name of the property whose getter should be returned.
The function bound as a getter to the specified property.
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()
.
var obj = {
get foo() {
return Math.random() > 0.5 ? 'foo' : 'bar';
}
};
// Non-standard and deprecated way
obj.__lookupGetter__('foo');
// (function() { return Math.random() > 0.5 ? 'foo' : 'bar'; })
// Standard-compliant way
Object.getOwnPropertyDescriptor(obj, "foo").get;
// (function() { return Math.random() > 0.5 ? 'foo' : 'bar'; })
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'Object.prototype.__lookupGetter__()' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
__lookupGetter__
弃用
|
Chrome 1 | Edge 12 | Firefox 1 | IE 11 | Opera 9.5 | Safari 3 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 1 | Samsung Internet Android 1.0 | nodejs Yes |
完整支持
弃用。不要用于新网站。
Object.prototype.__lookupSetter__()
get
operator
Object.getOwnPropertyDescriptor()
and
Object.getPrototypeOf()
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object
Object.assign()
Object.create()
Object.defineProperties()
Object.defineProperty()
Object.entries()
Object.freeze()
Object.fromEntries()
Object.getOwnPropertyDescriptor()
Object.getOwnPropertyDescriptors()
Object.getOwnPropertyNames()
Object.getOwnPropertySymbols()
Object.getPrototypeOf()
Object.is()
Object.isExtensible()
Object.isFrozen()
Object.isSealed()
Object.keys()
Object.preventExtensions()
Object.prototype.__defineGetter__()
Object.prototype.__defineSetter__()
Object.prototype.__lookupGetter__()
Object.prototype.__lookupSetter__()
Object.prototype.hasOwnProperty()
Object.prototype.isPrototypeOf()
Object.prototype.propertyIsEnumerable()
Object.prototype.toLocaleString()
Object.prototype.toSource()
Object.prototype.toString()
Object.prototype.valueOf()
Object.seal()
Object.setPrototypeOf()
Object.values()
Function