Determine whether a JavaScript array has an element in the specified index.


JS_HasElement(JSContext *cx, JS::HandleObject obj, uint32_t index, bool *foundp);
Name Type Description
cx JSContext * The context in which to perform the property lookup. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
obj JS::HandleObject The object to search for the element.
index uint32_t Index of the element to look up.
foundp bool * Out parameter. On success, it stores true to *foundp, false otherwise.


JS_HasElement examines a specified JS object, obj, and its prototype chain, for an element or numeric property numbered index.

If the element exists, JS_HasElement sets *foundp to true. If not, it sets *foundp to false and returns true (to indicate no error occurred). If the search fails with an error or exception, JS_HasElement returns false, and the value left in *foundp is undefined.

See Also

Document Tags and Contributors

 Contributors to this page: kscarfone, arai
 Last updated by: kscarfone,