JS_AliasProperty 编辑
Obsolete since JSAPI 8
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Create an alias for a native property.
Syntax
JSBool
JS_AliasProperty(JSContext *cx, JSObject *obj,
const char *name, const char *alias);
Name | Type | Description |
---|---|---|
cx | JSContext * | Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext . |
obj | JSObject * | Object for which to create the alias. |
name | const char * | Name of the property for which to create an alias. |
alias | const char * | Alias name to assign to the property. |
Description
JS_AliasProperty
assigns an alternate name for a property associated with a native object. obj
is the object to which the property belongs. name
is the property's current name in the object, and alias
is the alternate name to assign to the property.
Notes
This feature has been removed.
An alias does not replace a property's name; it supplements it, providing a second way to reference a property. If the alias is successfully created and associated with the property, JS_AliasProperty
returns JS_TRUE
. Creating an alias does not change the length of the property array.
If the property name you specify does not exist, JS_AliasProperty
reports an error, and returns JS_FALSE
. If the property is currently out of scope, already exists, or the alias itself cannot be assigned to the property, JS_AliasProperty
does not report an error, but returns JS_FALSE
.
Once you create an alias, you can reassign it to other properties as needed. Aliases can also be deleted. Deleting an alias does not delete the property to which it refers.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论