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);
Name | Type | Description |
---|---|---|
cx | JSContext * | 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 . |
obj | JS::HandleObject | The object to search. |
index | uint32_t | The numeric id of the property to look up. |
vp | JS::MutableHandleValue | Out 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论