Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

JS_SetElement

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_THREADSAFE build, the caller must be in a request on this JSContext.
obj JS::HandleObject The object to modify, commonly an Array object.
index uint32_t Index number of the element to set.
v JS::HandleValue or JS::HandleObject or JS::HandleString or int32_t or uint32_t or double The value to assign to the element. Added in SpiderMonkey 31
vp JS::MutableHandleValue In/out parameter. *vp is the value to assign to the element. JS_SetElement ordinarily leaves *vp unchanged, but a JSClass.addProperty hook or non-default setter may 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

Document Tags and Contributors

 Contributors to this page: arai, fscholz, Jorend, mauve, Dria, MMondor
 Last updated by: arai,