弃用
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() .

范例

Standard-compliant and non-standard ways to get a property setter

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.

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile Server
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet Node.js
__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

图例

完整支持

完整支持

弃用。不要用于新网站。

弃用。不要用于新网站。

另请参阅

元数据

  • 最后修改: