Property attributes 编辑
Any object property can have zero or more property attributes set.
Some property attributes are defined in the ECMAScript standard, in ECMA 262-3 §8.6.1. SpiderMonkey additionally defines several non-standard property attributes.
The JSAPI expresses property attributes as a value of type unsigned
, the bitwise OR of zero or more of the JSPROP
flags described below.
An application can set property attributes when creating a property. See JS_DefineProperty
, JS_FS
, and JS_FN
Flag | Description |
---|---|
JSPROP_ENUMERATE | The property is visible to JavaScript This is the inverse of the ECMA standard DontEnum attribute. |
JSPROP_READONLY | The property's value cannot be set. In JavaScript 1.2 and lower, it is an error to attempt to assign a value to a read-only property. In JavaScript 1.3 and higher, as in ECMAScript, attempts to set a value on a read-only property are ignored. This is the ECMA standard ReadOnly attribute. |
JSPROP_PERMANENT | The property cannot be deleted. In JavaScript 1.2 and lower, it is an error to attempt to delete a permanent property. In JavaScript 1.3 and higher, as in ECMAScript, such attempts are ignored. This is the ECMA standard DontDelete attribute. The JavaScript language does not provide any way for a script to delete a permanent property. |
JSPROP_PROPOP_ACCESSORS | Passed to |
JSPROP_GETTER | The property's getter is a JavaScript |
JSPROP_SETTER | The property's setter is a JavaScript |
JSPROP_SHARED | The property is shared. This is usually the right thing for properties that have getters or setters. This has three effects:
|
JSPROP_INDEX | The property's id is represented internally as an integer, not a string. Obsolete since JSAPI 39 This flag has an additional special meaning when used with |
JSPROP_DEFINE_LATE | Don't define property when initially creating the constructor. Some objects like Function/Object have self-hosted functions that can only be defined after the initialization is already finished. Added in SpiderMonkey 38 |
JSFUN_STUB_GSOPS | Use |
JSFUN_CONSTRUCTOR | Native that can be called as a constructor. Added in SpiderMonkey 17 |
JSPROP_REDEFINE_NONCONFIGURABLE | If set, will allow redefining a non-configurable property, but only on a non-DOM global. This is a temporary hack that will need to go away in bug 1105518. Added in SpiderMonkey 38 |
JSPROP_RESOLVING | Resolve hooks and enumerate hooks must pass this flag when calling
For enumerate hooks, triggering the resolve hook would be merely silly, not fatal, except in some cases involving non-configurable properties. Added in SpiderMonkey 45 |
JSPROP_IGNORE_ENUMERATE | Ignore the value in |
JSPROP_IGNORE_READONLY | Ignore the value in |
JSPROP_IGNORE_PERMANENT | Ignore the value in |
JSPROP_IGNORE_VALUE | Ignore the |
See Also
- bug 575997 - for
JSPROP_SHARED
- bug 1088002 - added
JSPROP_PROPOP_ACCESSORS
- bug 825199 - added
JSPROP_DEFINE_LATE
- bug 365851 - added
JSFUN_STUB_GSOPS
- bug 581263 - added
JSFUN_CONSTRUCTOR
- bug 1101123 - added
JSPROP_REDEFINE_NONCONFIGURABLE
- bug 1037770 - added
JSOP_IGNORE_*
- bug 1105518 - for
JSPROP_REDEFINE_NONCONFIGURABLE
- bug 1138489 - removed JSPROP_INDEX
- bug 1140482 - added JSPROP_RESOLVING
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论