Assign a value to a numeric property of an object.
Syntax
/* Added in SpiderMonkey 31 */
bool
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
              JS::HandleValue v);
bool
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
              JS::HandleObject v);
bool
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
              JS::HandleString v);
bool
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
              int32_t v);
bool
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
              uint32_t v);
bool
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
              double v);
/* Obsolete since JSAPI 29 */
bool
JS_SetElement(JSContext *cx, JS::HandleObject obj, uint32_t index,
              JS::MutableHandleValue vp);
| Name | Type | Description | 
|---|---|---|
| cx | JSContext * | The context in which to set the element. Requires request. In a JS_THREADSAFEbuild, the caller must be in a request on thisJSContext. | 
| obj | JS::HandleObject | The object to modify, commonly an Array object. | 
| index | uint32_t | Index number of the element to set. | 
| v | JS::HandleValueorJS::HandleObjectorJS::HandleStringorint32_toruint32_tordouble | The value to assign to the element. Added in SpiderMonkey 31 | 
| vp | JS::MutableHandleValue | In/out parameter. *vpis the value to assign to the element.JS_SetElementordinarily leaves*vpunchanged, but aJSClass.addPropertyhook or non-defaultsettermay modify it. Obsolete since JSAPI 29 | 
Description
JS_SetElement assigns a value to a numeric property of an object. It behaves like the JavaScript expression obj[index] = v.
On success, JS_SetElement returns true. On error or exception, JS_SetElement returns false.
Obsolete since JSAPI 29
On success, JS_SetElement returns true and the value left in *vp is left unchanged unless an addProperty hook or setter modified it. On error or exception, JS_SetElement returns false and the value left in *vp is unspecified.
See Also
- MXR ID Search for JS_SetElement
- bug 963167 - added v