JS_GetArrayLength 编辑
Retrieve the number of elements in an array object.
Syntax
bool
JS_GetArrayLength(JSContext *cx, JS::Handle<JSObject*> obj,
uint32_t *lengthp);
Name | Type | Description |
---|---|---|
cx | JSContext * | The context in which to look up the array's length. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext . |
obj | JS::Handle<JSObject*> | The object to examine. |
lengthp | uint32_t * | Out parameter. On success, *lengthp receives the length of the array. |
Description
JS_GetArrayLength
gets the .length
property of obj
as though by calling JS_GetProperty
and converts it to a 32-bit unsigned integer. If obj
is an array (see JS_IsArrayObject
), this is guaranteed to succeed, because the .length
property of an array is always a number and can't be deleted or redefined.
On success, JS_GetArrayLength
stores the length in *lengthp
and returns true
. On failure, it reports an error and returns false
, and the value left in *lengthp
is undefined.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论