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

Obsolete since JSAPI 8
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

Determines if an object has an array length property.

Syntax

JSBool
JS_HasArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information. Requires request. In a JS_THREADSAFE build, the caller must be in a request on this JSContext.
obj JSObject * Array object to get the length of.
lengthp jsuint * Out parameter. On success, *lengthp receives the length of the array.

Description

JS_HasArrayLength determines if an object, obj, has a length property. If the property exists, JS_HasArrayLength stores the current value of the property in *lengthp.

On success, JS_HasArrayLength returns JS_TRUE, and *lengthp receives the current value of the length property. On failure, JS_HasArrayLength returns JS_FALSE, and the value left in *lengthp is undefined.

This function differs from JS_GetArrayLength in the treatment of errors and unusual cases, like when an object's length is negative or not a number. This function may return JS_FALSE without having reported any error or exception.

See Also

Document Tags and Contributors

 Contributors to this page: arai, fscholz, tschneidereit, Jorend, Dria, MMondor, Nickolay, Tservo
 Last updated by: arai,