JS_HasArrayLength

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_HasArrayLength
  • Revision title: JS_HasArrayLength
  • Revision id: 146893
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment

Revision Content

{{template.Jsapi_ref_header("JS_HasArrayLength")}}

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. {{wiki.template('Jsapi-requires-request')}}
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. This function may return JS_FALSE without having reported any error or exception.

See Also

{{template.LXRSearch("ident", "i", "JS_HasArrayLength")}}

JS_AliasElement, JS_DefineElement, JS_DeleteElement, JS_GetArrayLength, JS_GetElement, JS_IsArrayObject, JS_LookupElement, JS_NewArrayObject, JS_SetArrayLength, JS_SetElement

Revision Source

<p>{{template.Jsapi_ref_header("JS_HasArrayLength")}}
</p><p>Determines if an object has an array length property.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval"><a href="en/JSBool">JSBool</a> <b>JS_HasArrayLength</b>(<a href="en/JSContext">JSContext</a> *cx, <a href="en/JSObject">JSObject</a> *obj,
    <a href="en/Jsuint">jsuint</a> *lengthp);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>cx</code></td>
<td><code><a href="en/JSContext">JSContext</a> *</code></td>
<td>Pointer to a JS context from which to derive runtime information.
{{wiki.template('Jsapi-requires-request')}}</td>
</tr>
<tr>
<td><code>obj</code></td>
<td><code><a href="en/JSObject">JSObject</a> *</code></td>
<td>Array object to get the length of.</td>
</tr>
<tr>
<td><code>lengthp</code></td>
<td><code><a href="en/Jsuint">jsuint</a> *</code></td>
<td>Out parameter.  On success, <code>*lengthp</code> receives the length of the array.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_HasArrayLength</code> determines if an object, <code>obj</code>, has a <code>length</code> property. If the property exists, <code>JS_HasArrayLength</code> stores the current value of the property in <code>*lengthp</code>.
</p><p>On success, <code>JS_HasArrayLength</code> returns <code>JS_TRUE</code>, and <code>*lengthp</code> receives the current value of the <code>length</code> property. On failure, <code>JS_HasArrayLength</code> returns <code>JS_FALSE</code>, and the value left in <code>*lengthp</code> is undefined.
</p><p>This function differs from <code><a href="en/JS_GetArrayLength">JS_GetArrayLength</a></code> in the treatment of errors and unusual cases.  This function may return <code>JS_FALSE</code> without having reported any error or exception.
</p>
<h2 name="See_Also"> See Also </h2>
<p>{{template.LXRSearch("ident", "i", "JS_HasArrayLength")}}
</p><p><a href="en/JS_AliasElement">JS_AliasElement</a>,
<a href="en/JS_DefineElement">JS_DefineElement</a>,
<a href="en/JS_DeleteElement">JS_DeleteElement</a>,
<a href="en/JS_GetArrayLength">JS_GetArrayLength</a>,
<a href="en/JS_GetElement">JS_GetElement</a>,
<a href="en/JS_IsArrayObject">JS_IsArrayObject</a>,
<a href="en/JS_LookupElement">JS_LookupElement</a>,
<a href="en/JS_NewArrayObject">JS_NewArrayObject</a>,
<a href="en/JS_SetArrayLength">JS_SetArrayLength</a>,
<a href="en/JS_SetElement">JS_SetElement</a>
</p>
Revert to this revision