弃用
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.
__lookupSetter__
method returns the function bound as a setter to the specified property.
obj.__lookupSetter__(sprop)
sprop
A string containing the name of the property whose setter should be returned.
The function bound as a setter to the specified property.
If a setter has been defined for an object's property, it was not possible to reference the setter function through that property, because that property refers to the return value of that function.
__lookupSetter__
can be used to obtain a reference to the setter function.
It is now possible to do this in a standardized way using
Object.getOwnPropertyDescriptor()
.
var obj = {
set foo(value) {
this.bar = value;
}
};
// Non-standard and deprecated way
obj.__lookupSetter__('foo')
// (function(value) { this.bar = value; })
// Standard-compliant way
Object.getOwnPropertyDescriptor(obj, 'foo').set;
// (function(value) { this.bar = value; })
| 规范 |
|---|
|
ECMAScript (ECMA-262)
The definition of 'Object.prototype.__lookupSetter__()' in that specification. |
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
__lookupSetter__
弃用
|
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.__lookupGetter__()
set
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