Entry: JS_SetArrayLength (Function)
Summary: Specifies the number of elements for an array object.
Syntax:
JSBool JS_SetArrayLength(JSContext *cx, JSObject *obj,
jsint length);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
obj JSObject * Array object for which to set the number of array elements.
length jsint Number of array elements to set.
Description:
JS_SetArrayLength specifies the number of elements for an array object, obj. length indicates the number of elements. If JS_SetArrayLength successfully sets the number of elements, it returns JS_TRUE. Otherwise it returns JS_FALSE.
You can call JS_SetArrayLength either to set the number of elements for an array object you created without specifying an initial number of elements, or to change the number of elements allocated for an array. If you set a shorter array length on an existing array, the elements that no longer fit in the array are destroyed.
See also:
|
|
|