JS_AliasElement 编辑

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 aliased index entry for an existing numeric property of a native object.

Syntax

JSBool
JS_AliasElement(JSContext *cx, JSObject *obj,
    const char *name, jsint alias);
NameTypeDescription
cxJSContext *The context in which to create the alias. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
objJSObject *The object for which to create the alias.
nameconst char *Name of the element for which to create an alias. This name corresponds to a string representation of the element's current index number.
aliasjsintAlias number to assign to the element.

Description

JS_AliasElement assigns an alternate index number for an element or numeric property associated with a native object. obj is the object to which the element belongs. name is the element's current index in the object, and alias is the alternate index to assign to the element.

This feature is deprecated, meaning that it is currently supported only for backward compatibility with existing applications. Future versions of the engine may no longer support this function.

An alias does not replace an element's current index number; it supplements it, providing a second way to reference the element. If the alias is successfully created and associated with the property, JS_AliasElement returns JS_TRUE. Adding an alias element does not change the element array length.

If the property name you specify does not exist, JS_AliasElement reports an error, and returns JS_FALSE. If the element is currently out of scope, already exists, or the alias itself cannot be assigned to the element, JS_AliasElement does not report an error, but returns JS_FALSE.

Once you create an alias, you can reassign it to other elements as needed. Aliases can also be deleted. Deleting an alias does not delete the element to which it refers.

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:43 次

字数:4673

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文