JS_LookupElement 编辑

Obsolete since JSAPI 37
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.

Determine if a specified numeric property exists.

Syntax

bool
JS_LookupElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
                 JS::MutableHandleValue vp);
NameTypeDescription
cxJSContext *The context in which to look up the property. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
objJS::HandleObjectThe object to search.
indexuint32_tThe numeric id of the property to look up.
vpJS::MutableHandleValueOut parameter. On success, *vp receives the stored value of obj[index], or undefined if the element does not exist.

Description

JS_LookupElement examines a specified JavaScript object, obj, for a numeric property numbered index.

Note: In the JavaScript language, numeric properties (also called "elements") are just ordinary properties whose names are numeric strings. For example, obj[6] is always exactly the same as obj["6"]. The ECMAScript standard also specifies this behavior: see ECMA 262-3 §11.2.1, step 6. So any call to JS_LookupElement is equivalent to a call to JS_LookupProperty passing a numeric string for the name.

If the property obj[index] exists, JS_LookupElement sets *vp to the property's stored value and returns true. If no such property exists, JS_LookupElement sets *vp to undefined and returns true (to indicate that no error occurred). On error or exception, JS_LookupElement returns false, and the value left in *vp is undefined.

JS_LookupElement does not distinguish between a property with a value of undefined and a property that does not exist.

See Also

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

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

发布评论

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

词条统计

浏览:146 次

字数:5148

最后编辑:7年前

编辑次数:0 次

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