Specifications
C-Level Extensibility 259
JSBool JS_GetElement()
Description
Reads a single element of an array object.
Arguments
JSContext *cx, JSObject *obj, unsigned int index, jsval *v
• cx is the opaque JSContext pointer that passed to the JavaScript function.
• obj is a pointer to an array object.
• index is an integer index into the array. The first element is index 0, and the last element is
index (
length - 1).
• v is a pointer to a jsval where the contents of the jsval in the array should be copied.
Returns
A Boolean value that indicates success (JS_TRUE) or failure (JS_FALSE).
JSBool JS_SetElement()
Description
Writes a single element of an array object.
Arguments
JSContext *cx, JSObject *obj, unsigned int index, jsval *v
• cx is the opaque JSContext pointer that was passed to the JavaScript function.
• obj is a pointer to an array object.
• index is an integer index into the array. The first element is index 0, and the last element is
index (
length - 1).
• v is a pointer to a jsval whose contents should be copied to the jsval in the array.
Returns
A Boolean value that indicates success (JS_TRUE) or failure (JS_FALSE).
JSBool JS_ExecuteScript()
Description
Compiles and executes a JavaScript string. If the script generates a return value, it returns in
*rval.
Arguments
JSContext *cx, JSObject *obj, char *script, unsigned int sz, jsval *rval
• cx is the opaque JSContext pointer that passed to the JavaScript function.
• obj is a pointer to the object in whose context the script executes. While the script is running,
the
this keyword is equal to this object. Usually this is the JSObject pointer that passed to
the JavaScript function.
• script is a string that contains JavaScript code. If the string size is not specified (see the sz
argument), the string must be null-terminated.