Visit Mozilla.org

JS GetArrayLength

From MDC

Retrieves the number of elements in an array object.

[edit] Syntax

JSBool JS_GetArrayLength(JSContext *cx, JSObject *obj,
    jsuint *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 JSObject * The array object to examine.
lengthp jsuint * Out parameter. On success, *lengthp receives the length of the array.

[edit] Description

JS_GetArrayLength reports the number of elements in an array object, obj. If the number of elements can be determined, JS_GetArrayLength reports the number of elements in lengthp and returns JS_TRUE. Otherwise, it returns JS_FALSE, and the value left in *lengthp is undefined.

[edit] See Also

LXR ID Search for JS_GetArrayLength

JS_GetElement, JS_IsArrayObject, JS_SetArrayLength