Entry: JS_SetElement (Function)
Summary: Sets the current value of an element or numeric property belonging to a specified object.
Syntax:
JSBool JS_SetElement(JSContext *cx, JSObject *obj, jsint index,
jsval *vp);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
obj JSObject * Array object to which the element to set belongs.
index jsint Index number of the element to set.
vp jsval * Pointer to the value to set for the element.
Description:
JS_SetElement sets the current value of an element or numeric property for a specified object. If the element does not exist, this function creates it, and inherits its attributes from a like-named element in the object's prototype chain. For elements it creates, JS_SetElement sets the JSPROP_ENUMERATE attribute in the element's flags field; all other values for the property are undefined.
index is element number to set, and vp is a pointer to the new value to set for the element. On successfully setting an element to a new value, JS_SetElement returns JS_TRUE. Otherwise it returns JS_FALSE.
If you attempt to set the value for a read-only element using JavaScript 1.2 or earlier, JS_SetElement reports an error and returns JS_FALSE. For JavaScript 1.3 and greater, such an attempt is silently ignored.
If you attempt to set the value for an element that does not exist, and there is a like-named read-only element in the object's prototype chain, JS_SetElement creates a new read-only element on the object, sets its value to JSVAL_VOID, and reports a read-only violation error.
See also:
|
|
|