JS_LookupProperty

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_LookupProperty
  • Revision title: JS_LookupProperty
  • Revision id: 71942
  • Created:
  • Creator: Tservo
  • Is current revision? No
  • Comment /* Description */

Revision Content

<title>JS_LookupProperty</title>

Summary

Function

Determines if a specified property exists.

Syntax

JSBool JS_LookupProperty(JSContext *cx, JSObject *obj,
                         const char *name, jsval *vp);
Name Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
obj JSObject * Object to search on for the property.
name const char * Name of the property to look up.
vp jsval * Pointer to a variable into which to store the last retrieved value of the property if it exists. If not, vp is set to JSVAL_VOID.

Description

JS_LookupProperty examines a specified JS object, obj, for a property named name. vp is set either to the last retrieved value of the property if it exists, or to JSVAL_VOID if it does not, and JS_LookupProperty returns JS_TRUE. On error, such as running out of memory during the search, JS_LookupProperty returns JS_FALSE, and vp is undefined.

Notes

JS_LookupProperty does not distunguish between a property with a value of undefined and a property that does not exist. Use JS_GetPropertyAttributes to distinguish these cases.

See Also

Groups Functions
Documents {{template.LXRSearch("ident", "i", "JS_LookupProperty", "LXR ID Search")}}
Entries

JS_MaybeGC, JS_malloc, JS_realloc

Revision Source

<p> &lt;title&gt;JS_LookupProperty&lt;/title&gt;
</p>
<h2 name="Summary"> Summary </h2>
<p><b>Function</b>
</p><p>Determines if a specified property exists.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre>JSBool JS_LookupProperty(JSContext *cx, JSObject *obj,
                         const char *name, jsval *vp);
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>cx</code></td>
<td>JSContext *</td>
<td>Pointer to a JS context from which to derive runtime information.</td>
</tr>
<tr>
<td><code>obj</code></td>
<td><code>JSObject *</code></td>
<td>Object to search on for the property.</td>
</tr>
<tr>
<td><code>name</code></td>
<td><code>const char *</code></td>
<td>Name of the property to look up.</td>
</tr>
<tr>
<td><code>vp</code></td>
<td><code>jsval *</code></td>
<td>Pointer to a variable into which to store the last retrieved value of the property if it exists. If not, <code>vp</code> is set to <code><a href="en/JSAPI_Reference/JSVAL_VOID">JSVAL_VOID</a></code>.</td>
</tr>
</tbody></table>
<h2 name="Description"> Description </h2>
<p><code>JS_LookupProperty</code> examines a specified JS object, <code>obj</code>, for a property named <code>name</code>. <code>vp</code> is set either to the last retrieved value of the property if it exists, or to <code><a href="en/JSAPI_Reference/JSVAL_VOID">JSVAL_VOID</a></code> if it does not, and <code>JS_LookupProperty</code> returns <code>JS_TRUE</code>. On error, such as running out of memory during the search, <code>JS_LookupProperty</code> returns <code>JS_FALSE</code>, and <code>vp</code> is undefined.
</p>
<h3 name="Notes"> Notes </h3>
<p><code>JS_LookupProperty</code> does not distunguish between a property with a value of <code>undefined</code> and a property that does not exist.  Use <code>JS_GetPropertyAttributes</code> to distinguish these cases.
</p>
<h2 name="See_Also"> See Also </h2>
<table class="fullwidth-table">
<tbody><tr>
<td>Groups</td>
<td><a href="en/JSAPI_Reference#Functions">Functions</a></td>
</tr>
<tr>
<td>Documents</td>
<td>{{template.LXRSearch("ident", "i", "JS_LookupProperty", "LXR ID Search")}}</td>
</tr>
<tr>
<td>Entries</td>
<td>
<p><a href="en/JSAPI_Reference/JS_MaybeGC">JS_MaybeGC</a>,
<a href="en/JSAPI_Reference/JS_malloc">JS_malloc</a>,
<a href="en/JSAPI_Reference/JS_realloc">JS_realloc</a>
</p>
</td>
</tr>
</tbody></table>
Revert to this revision