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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论